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] submodule: use the submodule repository to abbreviate commits
Date: Sun, 01 Nov 2026 13:45:42 -0800 [thread overview]
Message-ID: <xmqqecd4z0mx.fsf@gitster.g> (raw)
In-Reply-To: <pull.2288.v3.git.1793474657981.gitgitgadget@gmail.com> (Srujith A. Poojary via GitGitGadget's message of "Sat, 31 Oct 2026 19:24:17 +0000")
"Srujith A Poojary via GitGitGadget" <gitgitgadget@gmail.com>
writes:
> From: Srujith A Poojary <poojarysrujith@gmail.com>
>
> The commit IDs shown in a submodule diff header belong to the
> submodule's object database. However, strbuf_add_unique_abbrev()
> uses the_repository, so it checks the superproject's object
> database when abbreviating those IDs.
>
> Use the submodule repository when it is available, and fall back
> to the repository from the diff options when it is not.
While the fallback behaviour does not make much sense (the commit
object recorded in gitlink is not expected to be found in the
superproject's repository, which is the reason why you are adding
this fix in the first place), it would mean that for unpopulated
submodules for which you haven't run "git submodule init", the
behaviour would stay the ame as before.
> 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;
> const char *message = NULL;
> struct strbuf sb = STRBUF_INIT;
> int fast_forward = 0, fast_backward = 0;
> @@ -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);
> if (message)
> strbuf_addf(&sb, " %s\n", message);
> else
Quite straightforward.
> +test_expect_success SHA1 'submodule commit abbreviation uses submodule object database' '
Hmph. I wonder if there is a way to use the test_oid_cache
facility to allow test with both SHA-1 and SHA-256 hashes?
Will queue.
Thanks.
next prev parent reply other threads:[~2026-11-01 21:45 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-31 8:25 [PATCH] [Outreachy PATCH] t4041: use submodule repository for commit abbreviations Srujith A Poojary via GitGitGadget
2026-10-31 16:46 ` Okhuomon Ajayi
2026-10-31 19:08 ` Srujith Poojary
2026-10-31 18:57 ` [PATCH v2] Submodule: use the submodule repository to abbreviate commits Srujith A Poojary via GitGitGadget
2026-10-31 19:09 ` Okhuomon Ajayi
2026-10-31 19:37 ` Srujith Poojary
2026-10-31 19:24 ` [PATCH v3] submodule: " Srujith A Poojary via GitGitGadget
2026-11-01 21:45 ` Junio C Hamano [this message]
2026-11-02 19:40 ` [PATCH v4 0/2] [Outreachy PATCH] t4041: use submodule repository for commit abbreviations Srujith A Poojary via GitGitGadget
2026-11-02 19:40 ` [PATCH v4 1/2] submodule: use the submodule repository to abbreviate commits Srujith A Poojary via GitGitGadget
2026-11-02 19:49 ` Srujith Poojary
2026-11-02 19:40 ` [PATCH v4 2/2] t4041: test SHA-256 submodule abbreviations 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=xmqqecd4z0mx.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