From: Junio C Hamano <gitster@pobox.com>
To: "Srujith A Poojary via GitGitGadget" <gitgitgadget@gmail.com>
Cc: git@vger.kernel.org, Srujith A Poojary <poojarysrujith@gmail.com>
Subject: Re: [PATCH v3 1/2] submodule: use the submodule repository to abbreviate commits
Date: Tue, 10 Nov 2026 12:26:29 -0800 [thread overview]
Message-ID: <xmqq7bikqvpm.fsf@gitster.g> (raw)
In-Reply-To: <01c3cc25738c43d61aff153805e02db872ff21de.1794335969.git.gitgitgadget@gmail.com> (Srujith A. Poojary via GitGitGadget's message of "Tue, 10 Nov 2026 18:39:28 +0000")
"Srujith A Poojary via GitGitGadget" <gitgitgadget@gmail.com>
writes:
> diff --git a/submodule.c b/submodule.c
> index 6fcb606f7e..1302c11ddf 100644
> --- a/submodule.c
> +++ b/submodule.c
> @@ -543,6 +543,7 @@ static void show_submodule_header(struct diff_options *o,
> struct commit **left, struct commit **right,
> struct commit_list **merge_bases)
> {
> + struct repository *repo = sub ? sub : o->repo;
Let's step back a bit. Use of any repository other than 'sub' is
wrong as a way to correctly find suitable abbreviation of object
names in the 'sub' repository. Now, the variable sub is NULL when
the submodule is not initialized, in which case we won't know how
many hexdigits we need to abbreviate "one" and "two" to, because
there is no repository that has any object from that submodule to
begin with.
> @@ -599,9 +600,9 @@ static void show_submodule_header(struct diff_options *o,
>
> output_header:
> strbuf_addf(&sb, "Submodule %s ", path);
> - strbuf_add_unique_abbrev(&sb, one, DEFAULT_ABBREV);
> + strbuf_repo_add_unique_abbrev(&sb, repo, one, DEFAULT_ABBREV);
> strbuf_addstr(&sb, (fast_backward || fast_forward) ? ".." : "...");
> - strbuf_add_unique_abbrev(&sb, two, DEFAULT_ABBREV);
> + strbuf_repo_add_unique_abbrev(&sb, repo, two, DEFAULT_ABBREV);
And that means the above patch is an utterly wrong rewrite, isn't
it?
Because using o->repo is just as wrong as using the_repository,
replacing strbuf_add_unique_abbrev(), which uses the_repository,
with a call to strbuf_repo_add_unique_abbrev() and using o->repo
does not fix anything.
So when (sub == NULL), the code probably should just grab the first
DEFAULT_ABBREV hexdigits of one and two and be done with it.
Guaranteeing uniqueness of the abbreviations within o->repo does not
help anybody anyway, right?
On the other hand, when (sub != NULL), the rewrite in this patch is
absolutely the right thing to do. Thanks for working on it.
next prev parent reply other threads:[~2026-11-10 20:26 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-09 19:04 [PATCH 0/2] [Outreachy PATCH] archive: remove USE_THE_REPOSITORY_VARIABLE from archival modules Srujith A Poojary via GitGitGadget
2026-11-09 19:04 ` [PATCH 1/2] submodule: use the submodule repository to abbreviate commits Srujith A Poojary via GitGitGadget
2026-11-09 19:05 ` [PATCH 2/2] archive: remove USE_THE_REPOSITORY_VARIABLE from archival modules Srujith A Poojary via GitGitGadget
2026-11-09 20:45 ` Junio C Hamano
2026-11-10 8:13 ` Srujith Poojary
2026-11-10 6:03 ` [PATCH v2 0/2] [Outreachy PATCH] " Srujith A Poojary via GitGitGadget
2026-11-10 6:03 ` [PATCH v2 1/2] submodule: use the submodule repository to abbreviate commits Srujith A Poojary via GitGitGadget
2026-11-10 6:03 ` [PATCH v2 2/2] archive: remove USE_THE_REPOSITORY_VARIABLE from archival modules Srujith A Poojary via GitGitGadget
2026-11-10 16:07 ` Junio C Hamano
2026-11-10 18:33 ` Srujith Poojary
2026-11-10 18:39 ` [PATCH v3 0/2] [Outreachy PATCH] " Srujith A Poojary via GitGitGadget
2026-11-10 18:39 ` [PATCH v3 1/2] submodule: use the submodule repository to abbreviate commits Srujith A Poojary via GitGitGadget
2026-11-10 20:26 ` Junio C Hamano [this message]
2026-11-11 4:19 ` Srujith Poojary
2026-11-10 18:39 ` [PATCH v3 2/2] archive: remove USE_THE_REPOSITORY_VARIABLE from archival modules Srujith A Poojary via GitGitGadget
2026-11-10 20:40 ` Junio C Hamano
2026-11-11 4:17 ` Srujith Poojary
2026-11-11 8:34 ` Srujith Poojary
2026-11-10 19:17 ` [PATCH v3 0/2] [Outreachy PATCH] " Junio C Hamano
2026-11-11 8:25 ` [PATCH v4] " Srujith A Poojary via GitGitGadget
2026-11-11 11:08 ` Karthik Nayak
2026-11-11 12:24 ` Srujith Poojary
2026-11-11 12:45 ` [PATCH v5] archive-tar: add comments explaining configuration precedence Srujith A Poojary via GitGitGadget
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=xmqq7bikqvpm.fsf@gitster.g \
--to=gitster@pobox.com \
--cc=git@vger.kernel.org \
--cc=gitgitgadget@gmail.com \
--cc=poojarysrujith@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox