{"thread":{"id":"66723","subject":"[PATCH] [Outreachy PATCH] t4041: use submodule repository for commit abbreviations","startedAt":"2026-10-31T08:25:49Z","lastAt":"2026-11-04T19:45:54Z","messageCount":18,"participants":["Srujith A Poojary via GitGitGadget","Okhuomon Ajayi","Srujith Poojary","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"556999","messageId":"pull.2288.git.1793435149942.gitgitgadget@gmail.com","threadId":"66723","inReplyTo":null,"subject":"[PATCH] [Outreachy PATCH] t4041: use submodule repository for commit abbreviations","fromName":"Srujith A Poojary via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2026-10-31T08:25:49Z","receivedAt":"2026-10-31T08:25:49Z","isPatch":true,"sender":{"key":"name:Srujith A Poojary","avatar":null},"body":"From: Srujith A Poojary <poojarysrujith@gmail.com>\n\nUse the submodule repository when abbreviating commit IDs in\nsubmodule diff headers, so uniqueness is checked against the\ncorrect object database.\n\nSigned-off-by: Srujith A Poojary <poojarysrujith@gmail.com>\n---\n    [Outreachy PATCH] t4041: use submodule repository for commit\n    abbreviations\n\nPublished-As: https://github.com/gitgitgadget/git/releases/tag/pr-2288%2Fpoojarysrujith%2Fmicroproject-git-libification-v1\nFetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-2288/poojarysrujith/microproject-git-libification-v1\nPull-Request: https://github.com/gitgitgadget/git/pull/2288\n\n submodule.c                      | 10 ++++++++--\n t/t4041-diff-submodule-option.sh | 18 ++++++++++++++++++\n 2 files changed, 26 insertions(+), 2 deletions(-)\n\ndiff --git a/submodule.c b/submodule.c\nindex 6fcb606f7e..2215a50d9c 100644\n--- a/submodule.c\n+++ b/submodule.c\n@@ -599,9 +599,15 @@ static void show_submodule_header(struct diff_options *o,\n \n output_header:\n \tstrbuf_addf(&sb, \"Submodule %s \", path);\n-\tstrbuf_add_unique_abbrev(&sb, one, DEFAULT_ABBREV);\n+\tif (sub)\n+\t\tstrbuf_repo_add_unique_abbrev(&sb, sub, one, DEFAULT_ABBREV);\n+\telse\n+\t\tstrbuf_add_unique_abbrev(&sb, one, DEFAULT_ABBREV);\n \tstrbuf_addstr(&sb, (fast_backward || fast_forward) ? \"..\" : \"...\");\n-\tstrbuf_add_unique_abbrev(&sb, two, DEFAULT_ABBREV);\n+\tif (sub)\n+\t\tstrbuf_repo_add_unique_abbrev(&sb, sub, two, DEFAULT_ABBREV);\n+\telse\n+\t\tstrbuf_add_unique_abbrev(&sb, two, DEFAULT_ABBREV);\n \tif (message)\n \t\tstrbuf_addf(&sb, \" %s\\n\", message);\n \telse\ndiff --git a/t/t4041-diff-submodule-option.sh b/t/t4041-diff-submodule-option.sh\nindex 4dd4954260..e80472af32 100755\n--- a/t/t4041-diff-submodule-option.sh\n+++ b/t/t4041-diff-submodule-option.sh\n@@ -14,6 +14,24 @@ export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME\n \n . ./test-lib.sh\n \n+test_expect_success SHA1 'submodule commit abbreviation uses submodule object database' '\n+\ttest_when_finished \"rm -rf collision-super\" &&\n+\tgit init -q collision-super &&\n+\tgit init -q collision-super/sm1 &&\n+\tprintf \"0\\n1\\n2\\n3\\n4\\n5\\n6\\n7\\n8\\n9\\n\\nb1rwzyc3\\n\" >collision-super/sm1/a0blgqsjc &&\n+\tgit -C collision-super/sm1 add a0blgqsjc &&\n+\ttree=$(git -C collision-super/sm1 write-tree) &&\n+\tcommit1=$(GIT_AUTHOR_DATE=\"1112911993 -0700\" GIT_COMMITTER_DATE=\"1112911993 -0700\" git -C collision-super/sm1 commit-tree \"$tree\" -m a2onsxbvj) &&\n+\tcommit2=$(printf \"child\\n\" | GIT_AUTHOR_DATE=\"1112912053 -0700\" GIT_COMMITTER_DATE=\"1112912053 -0700\" git -C collision-super/sm1 commit-tree \"$tree\" -p \"$commit1\") &&\n+\tgit -C collision-super/sm1 checkout -q \"$commit2\" &&\n+\tgit -C collision-super update-index --add --cacheinfo 160000,\"$commit1\",sm1 &&\n+\tgit -C collision-super commit -q -m \"Add submodule\" &&\n+\tgit -C collision-super diff --submodule=log >actual &&\n+\tprintf \"Submodule sm1 0000000000e..%s:\\n  > child\\n\" \\\n+\t\t\"$(git -C collision-super/sm1 rev-parse --short \"$commit2\")\" >expected &&\n+\ttest_cmp expected actual\n+'\n+\n # Test non-UTF-8 encoding in case iconv is available.\n if test_have_prereq ICONV\n then\n\nbase-commit: 50fe5cc63f9cd6e89b87a2c9ccf96a444f4cfdb7\n-- \ngitgitgadget\n\n"},{"id":"557033","messageId":"CAFpMFfALb1KbEw-dc4wYCxS4PXfDBwzQOD6YPRe52_bpRnGt9w@mail.gmail.com","threadId":"66723","inReplyTo":"pull.2288.git.1793435149942.gitgitgadget@gmail.com","subject":"Re: [PATCH] [Outreachy PATCH] t4041: use submodule repository for commit abbreviations","fromName":"Okhuomon Ajayi","fromEmail":"okhuomonajayi54@gmail.com","sentAt":"2026-10-31T16:46:21Z","receivedAt":"2026-10-31T16:46:21Z","isPatch":true,"sender":{"key":"okhuomonajayi54@gmail.com","avatar":null},"body":"Hi Srujith,\n\nI applied this on top of master and ran t4041. The new test fails\nwithout the submodule.c change and passes with it, so it does catch\nthe problem.\n\nA few small things:\n\nOn Sat, Oct 31, 2026 at 9:26 AM Srujith A Poojary via GitGitGadget\n<gitgitgadget@gmail.com> wrote:\n> Use the submodule repository when abbreviating commit IDs in\n> submodule diff headers, so uniqueness is checked against the\n> correct object database.\n\nIt would help to first describe what happens today: the commit IDs\nin the \"Submodule ...\" header are abbreviated against the\nsuperproject's objects, even though the commits live in the\nsubmodule, so the abbreviation may not be unique there.\n\n> [Outreachy PATCH] t4041: use submodule repository for commit\n> abbreviations\n\nThe change itself is in submodule.c, so the title might read better\nwith that area, e.g. \"submodule: use the submodule repository to\nabbreviate commits\".\n\n> - strbuf_add_unique_abbrev(&sb, one, DEFAULT_ABBREV);\n> + if (sub)\n> + strbuf_repo_add_unique_abbrev(&sb, sub, one, DEFAULT_ABBREV);\n> + else\n> + strbuf_add_unique_abbrev(&sb, one, DEFAULT_ABBREV);\n\nThe same if/else appears twice. Maybe choose the repository once,\nat the top of the function, and call strbuf_repo_add_unique_abbrev()\nwith it in both places. I also wonder whether the fallback could be\no->repo instead of the_repository, since the diff options already\ncarry a repository.\n\nThanks,\nOkhuomon\n\n"},{"id":"557042","messageId":"pull.2288.v2.git.1793473062113.gitgitgadget@gmail.com","threadId":"66723","inReplyTo":"pull.2288.git.1793435149942.gitgitgadget@gmail.com","subject":"[PATCH v2] Submodule: use the submodule repository to abbreviate commits","fromName":"Srujith A Poojary via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2026-10-31T18:57:42Z","receivedAt":"2026-10-31T18:57:42Z","isPatch":true,"sender":{"key":"name:Srujith A Poojary","avatar":null},"body":"From: Srujith A Poojary <poojarysrujith@gmail.com>\n\nThe commit IDs shown in a submodule diff header belong to the\nsubmodule's object database. However, strbuf_add_unique_abbrev()\nuses the_repository, so it checks the superproject's object\ndatabase when abbreviating those IDs.\n\nUse the submodule repository when it is available, and fall back\nto the repository from the diff options when it is not.\n\nSigned-off-by: Srujith A Poojary <poojarysrujith@gmail.com>\n---\n    [Outreachy PATCH] t4041: use submodule repository for commit\n    abbreviations\n\nPublished-As: https://github.com/gitgitgadget/git/releases/tag/pr-2288%2Fpoojarysrujith%2Fmicroproject-git-libification-v2\nFetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-2288/poojarysrujith/microproject-git-libification-v2\nPull-Request: https://github.com/gitgitgadget/git/pull/2288\n\nRange-diff vs v1:\n\n 1:  7b2af1b46a ! 1:  3133cd3017 [Outreachy PATCH] t4041: use submodule repository for commit abbreviations\n     @@ Metadata\n      Author: Srujith A Poojary <poojarysrujith@gmail.com>\n      \n       ## Commit message ##\n     -    [Outreachy PATCH] t4041: use submodule repository for commit abbreviations\n     +    Submodule: use the submodule repository to abbreviate commits\n      \n     -    Use the submodule repository when abbreviating commit IDs in\n     -    submodule diff headers, so uniqueness is checked against the\n     -    correct object database.\n     +    The commit IDs shown in a submodule diff header belong to the\n     +    submodule's object database. However, strbuf_add_unique_abbrev()\n     +    uses the_repository, so it checks the superproject's object\n     +    database when abbreviating those IDs.\n     +\n     +    Use the submodule repository when it is available, and fall back\n     +    to the repository from the diff options when it is not.\n      \n          Signed-off-by: Srujith A Poojary <poojarysrujith@gmail.com>\n      \n       ## submodule.c ##\n      @@ submodule.c: static void show_submodule_header(struct diff_options *o,\n     + \t\tstruct commit **left, struct commit **right,\n     + \t\tstruct commit_list **merge_bases)\n     + {\n     ++\tstruct repository *repo = sub ? sub : o->repo;\n     + \tconst char *message = NULL;\n     + \tstruct strbuf sb = STRBUF_INIT;\n     + \tint fast_forward = 0, fast_backward = 0;\n     +@@ submodule.c: static void show_submodule_header(struct diff_options *o,\n       \n       output_header:\n       \tstrbuf_addf(&sb, \"Submodule %s \", path);\n      -\tstrbuf_add_unique_abbrev(&sb, one, DEFAULT_ABBREV);\n     -+\tif (sub)\n     -+\t\tstrbuf_repo_add_unique_abbrev(&sb, sub, one, DEFAULT_ABBREV);\n     -+\telse\n     -+\t\tstrbuf_add_unique_abbrev(&sb, one, DEFAULT_ABBREV);\n     ++\tstrbuf_repo_add_unique_abbrev(&sb, repo, one, DEFAULT_ABBREV);\n       \tstrbuf_addstr(&sb, (fast_backward || fast_forward) ? \"..\" : \"...\");\n      -\tstrbuf_add_unique_abbrev(&sb, two, DEFAULT_ABBREV);\n     -+\tif (sub)\n     -+\t\tstrbuf_repo_add_unique_abbrev(&sb, sub, two, DEFAULT_ABBREV);\n     -+\telse\n     -+\t\tstrbuf_add_unique_abbrev(&sb, two, DEFAULT_ABBREV);\n     ++\tstrbuf_repo_add_unique_abbrev(&sb, repo, two, DEFAULT_ABBREV);\n       \tif (message)\n       \t\tstrbuf_addf(&sb, \" %s\\n\", message);\n       \telse\n\n\n submodule.c                      |  5 +++--\n t/t4041-diff-submodule-option.sh | 18 ++++++++++++++++++\n 2 files changed, 21 insertions(+), 2 deletions(-)\n\ndiff --git a/submodule.c b/submodule.c\nindex 6fcb606f7e..1302c11ddf 100644\n--- a/submodule.c\n+++ b/submodule.c\n@@ -543,6 +543,7 @@ static void show_submodule_header(struct diff_options *o,\n \t\tstruct commit **left, struct commit **right,\n \t\tstruct commit_list **merge_bases)\n {\n+\tstruct repository *repo = sub ? sub : o->repo;\n \tconst char *message = NULL;\n \tstruct strbuf sb = STRBUF_INIT;\n \tint fast_forward = 0, fast_backward = 0;\n@@ -599,9 +600,9 @@ static void show_submodule_header(struct diff_options *o,\n \n output_header:\n \tstrbuf_addf(&sb, \"Submodule %s \", path);\n-\tstrbuf_add_unique_abbrev(&sb, one, DEFAULT_ABBREV);\n+\tstrbuf_repo_add_unique_abbrev(&sb, repo, one, DEFAULT_ABBREV);\n \tstrbuf_addstr(&sb, (fast_backward || fast_forward) ? \"..\" : \"...\");\n-\tstrbuf_add_unique_abbrev(&sb, two, DEFAULT_ABBREV);\n+\tstrbuf_repo_add_unique_abbrev(&sb, repo, two, DEFAULT_ABBREV);\n \tif (message)\n \t\tstrbuf_addf(&sb, \" %s\\n\", message);\n \telse\ndiff --git a/t/t4041-diff-submodule-option.sh b/t/t4041-diff-submodule-option.sh\nindex 4dd4954260..e80472af32 100755\n--- a/t/t4041-diff-submodule-option.sh\n+++ b/t/t4041-diff-submodule-option.sh\n@@ -14,6 +14,24 @@ export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME\n \n . ./test-lib.sh\n \n+test_expect_success SHA1 'submodule commit abbreviation uses submodule object database' '\n+\ttest_when_finished \"rm -rf collision-super\" &&\n+\tgit init -q collision-super &&\n+\tgit init -q collision-super/sm1 &&\n+\tprintf \"0\\n1\\n2\\n3\\n4\\n5\\n6\\n7\\n8\\n9\\n\\nb1rwzyc3\\n\" >collision-super/sm1/a0blgqsjc &&\n+\tgit -C collision-super/sm1 add a0blgqsjc &&\n+\ttree=$(git -C collision-super/sm1 write-tree) &&\n+\tcommit1=$(GIT_AUTHOR_DATE=\"1112911993 -0700\" GIT_COMMITTER_DATE=\"1112911993 -0700\" git -C collision-super/sm1 commit-tree \"$tree\" -m a2onsxbvj) &&\n+\tcommit2=$(printf \"child\\n\" | GIT_AUTHOR_DATE=\"1112912053 -0700\" GIT_COMMITTER_DATE=\"1112912053 -0700\" git -C collision-super/sm1 commit-tree \"$tree\" -p \"$commit1\") &&\n+\tgit -C collision-super/sm1 checkout -q \"$commit2\" &&\n+\tgit -C collision-super update-index --add --cacheinfo 160000,\"$commit1\",sm1 &&\n+\tgit -C collision-super commit -q -m \"Add submodule\" &&\n+\tgit -C collision-super diff --submodule=log >actual &&\n+\tprintf \"Submodule sm1 0000000000e..%s:\\n  > child\\n\" \\\n+\t\t\"$(git -C collision-super/sm1 rev-parse --short \"$commit2\")\" >expected &&\n+\ttest_cmp expected actual\n+'\n+\n # Test non-UTF-8 encoding in case iconv is available.\n if test_have_prereq ICONV\n then\n\nbase-commit: 50fe5cc63f9cd6e89b87a2c9ccf96a444f4cfdb7\n-- \ngitgitgadget\n\n"},{"id":"557043","messageId":"CABh_KWh0N0y7rN61wx5=zQWs3QmD8Ho6ONig75ocj8zFWKh4bw@mail.gmail.com","threadId":"66723","inReplyTo":"CAFpMFfALb1KbEw-dc4wYCxS4PXfDBwzQOD6YPRe52_bpRnGt9w@mail.gmail.com","subject":"Re: [PATCH] [Outreachy PATCH] t4041: use submodule repository for commit abbreviations","fromName":"Srujith Poojary","fromEmail":"poojarysrujith@gmail.com","sentAt":"2026-10-31T19:08:18Z","receivedAt":"2026-10-31T19:08:18Z","isPatch":true,"sender":{"key":"poojarysrujith@gmail.com","avatar":null},"body":"On Sat, Oct 31, 2026 at 10:16 PM Okhuomon Ajayi\n<okhuomonajayi54@gmail.com> wrote:\n>\n> Hi Srujith,\n>\n> I applied this on top of master and ran t4041. The new test fails\n> without the submodule.c change and passes with it, so it does catch\n> the problem.\n>\n> A few small things:\n>\n> On Sat, Oct 31, 2026 at 9:26 AM Srujith A Poojary via GitGitGadget\n> <gitgitgadget@gmail.com> wrote:\n> > Use the submodule repository when abbreviating commit IDs in\n> > submodule diff headers, so uniqueness is checked against the\n> > correct object database.\n>\n> It would help to first describe what happens today: the commit IDs\n> in the \"Submodule ...\" header are abbreviated against the\n> superproject's objects, even though the commits live in the\n> submodule, so the abbreviation may not be unique there.\n>\n> > [Outreachy PATCH] t4041: use submodule repository for commit\n> > abbreviations\n>\n> The change itself is in submodule.c, so the title might read better\n> with that area, e.g. \"submodule: use the submodule repository to\n> abbreviate commits\".\n>\n> > - strbuf_add_unique_abbrev(&sb, one, DEFAULT_ABBREV);\n> > + if (sub)\n> > + strbuf_repo_add_unique_abbrev(&sb, sub, one, DEFAULT_ABBREV);\n> > + else\n> > + strbuf_add_unique_abbrev(&sb, one, DEFAULT_ABBREV);\n>\n> The same if/else appears twice. Maybe choose the repository once,\n> at the top of the function, and call strbuf_repo_add_unique_abbrev()\n> with it in both places. I also wonder whether the fallback could be\n> o->repo instead of the_repository, since the diff options already\n> carry a repository.\n>\n> Thanks,\n> Okhuomon\n\nHi Okhuomon,\n\nThanks for reviewing the patch and testing the new test case.\n\nI've made the suggested changes and submitted v2. I now use `sub` when\navailable and fall back to `o->repo` when it isn't. I also simplified\nthe code and updated the commit message.\n\nHere is the updated patch:\nhttps://lore.kernel.org/git/pull.2288.v2.git.1793473062113.gitgitgadget@gmail.com\n\nThanks again!\n\nRegards,\nSrujith\n\n"},{"id":"557044","messageId":"CAFpMFfAeMtJ=qTt757aEvMfFyw1nEkB8d07b4wgaTJuQ2tnKiQ@mail.gmail.com","threadId":"66723","inReplyTo":"pull.2288.v2.git.1793473062113.gitgitgadget@gmail.com","subject":"Re: [PATCH v2] Submodule: use the submodule repository to abbreviate commits","fromName":"Okhuomon Ajayi","fromEmail":"okhuomonajayi54@gmail.com","sentAt":"2026-10-31T19:09:07Z","receivedAt":"2026-10-31T19:09:07Z","isPatch":true,"sender":{"key":"okhuomonajayi54@gmail.com","avatar":null},"body":"Hi Srujith,\n\nOn Sat, Oct 31, 2026 at 7:57 PM Srujith A Poojary via GitGitGadget\n<gitgitgadget@gmail.com> wrote:\n> + struct repository *repo = sub ? sub : o->repo;\n\nThanks, v2 looks good to me.\n\n> Submodule: use the submodule repository to abbreviate commits\n\nOne small nit: \"git log --no-merges submodule.c\" shows the area is\nalways written in lowercase (\"submodule:\"), so \"submodule: use the\nsubmodule repository to abbreviate commits\" would match.\n\nThanks,\nOkhuomon\n\nOn Sat, Oct 31, 2026 at 7:57 PM Srujith A Poojary via GitGitGadget\n<gitgitgadget@gmail.com> wrote:\n>\n> From: Srujith A Poojary <poojarysrujith@gmail.com>\n>\n> The commit IDs shown in a submodule diff header belong to the\n> submodule's object database. However, strbuf_add_unique_abbrev()\n> uses the_repository, so it checks the superproject's object\n> database when abbreviating those IDs.\n>\n> Use the submodule repository when it is available, and fall back\n> to the repository from the diff options when it is not.\n>\n> Signed-off-by: Srujith A Poojary <poojarysrujith@gmail.com>\n> ---\n>     [Outreachy PATCH] t4041: use submodule repository for commit\n>     abbreviations\n>\n> Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-2288%2Fpoojarysrujith%2Fmicroproject-git-libification-v2\n> Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-2288/poojarysrujith/microproject-git-libification-v2\n> Pull-Request: https://github.com/gitgitgadget/git/pull/2288\n>\n> Range-diff vs v1:\n>\n>  1:  7b2af1b46a ! 1:  3133cd3017 [Outreachy PATCH] t4041: use submodule repository for commit abbreviations\n>      @@ Metadata\n>       Author: Srujith A Poojary <poojarysrujith@gmail.com>\n>\n>        ## Commit message ##\n>      -    [Outreachy PATCH] t4041: use submodule repository for commit abbreviations\n>      +    Submodule: use the submodule repository to abbreviate commits\n>\n>      -    Use the submodule repository when abbreviating commit IDs in\n>      -    submodule diff headers, so uniqueness is checked against the\n>      -    correct object database.\n>      +    The commit IDs shown in a submodule diff header belong to the\n>      +    submodule's object database. However, strbuf_add_unique_abbrev()\n>      +    uses the_repository, so it checks the superproject's object\n>      +    database when abbreviating those IDs.\n>      +\n>      +    Use the submodule repository when it is available, and fall back\n>      +    to the repository from the diff options when it is not.\n>\n>           Signed-off-by: Srujith A Poojary <poojarysrujith@gmail.com>\n>\n>        ## submodule.c ##\n>       @@ submodule.c: static void show_submodule_header(struct diff_options *o,\n>      +          struct commit **left, struct commit **right,\n>      +          struct commit_list **merge_bases)\n>      + {\n>      ++ struct repository *repo = sub ? sub : o->repo;\n>      +  const char *message = NULL;\n>      +  struct strbuf sb = STRBUF_INIT;\n>      +  int fast_forward = 0, fast_backward = 0;\n>      +@@ submodule.c: static void show_submodule_header(struct diff_options *o,\n>\n>        output_header:\n>         strbuf_addf(&sb, \"Submodule %s \", path);\n>       - strbuf_add_unique_abbrev(&sb, one, DEFAULT_ABBREV);\n>      -+ if (sub)\n>      -+         strbuf_repo_add_unique_abbrev(&sb, sub, one, DEFAULT_ABBREV);\n>      -+ else\n>      -+         strbuf_add_unique_abbrev(&sb, one, DEFAULT_ABBREV);\n>      ++ strbuf_repo_add_unique_abbrev(&sb, repo, one, DEFAULT_ABBREV);\n>         strbuf_addstr(&sb, (fast_backward || fast_forward) ? \"..\" : \"...\");\n>       - strbuf_add_unique_abbrev(&sb, two, DEFAULT_ABBREV);\n>      -+ if (sub)\n>      -+         strbuf_repo_add_unique_abbrev(&sb, sub, two, DEFAULT_ABBREV);\n>      -+ else\n>      -+         strbuf_add_unique_abbrev(&sb, two, DEFAULT_ABBREV);\n>      ++ strbuf_repo_add_unique_abbrev(&sb, repo, two, DEFAULT_ABBREV);\n>         if (message)\n>                 strbuf_addf(&sb, \" %s\\n\", message);\n>         else\n>\n>\n>  submodule.c                      |  5 +++--\n>  t/t4041-diff-submodule-option.sh | 18 ++++++++++++++++++\n>  2 files changed, 21 insertions(+), 2 deletions(-)\n>\n> diff --git a/submodule.c b/submodule.c\n> index 6fcb606f7e..1302c11ddf 100644\n> --- a/submodule.c\n> +++ b/submodule.c\n> @@ -543,6 +543,7 @@ static void show_submodule_header(struct diff_options *o,\n>                 struct commit **left, struct commit **right,\n>                 struct commit_list **merge_bases)\n>  {\n> +       struct repository *repo = sub ? sub : o->repo;\n>         const char *message = NULL;\n>         struct strbuf sb = STRBUF_INIT;\n>         int fast_forward = 0, fast_backward = 0;\n> @@ -599,9 +600,9 @@ static void show_submodule_header(struct diff_options *o,\n>\n>  output_header:\n>         strbuf_addf(&sb, \"Submodule %s \", path);\n> -       strbuf_add_unique_abbrev(&sb, one, DEFAULT_ABBREV);\n> +       strbuf_repo_add_unique_abbrev(&sb, repo, one, DEFAULT_ABBREV);\n>         strbuf_addstr(&sb, (fast_backward || fast_forward) ? \"..\" : \"...\");\n> -       strbuf_add_unique_abbrev(&sb, two, DEFAULT_ABBREV);\n> +       strbuf_repo_add_unique_abbrev(&sb, repo, two, DEFAULT_ABBREV);\n>         if (message)\n>                 strbuf_addf(&sb, \" %s\\n\", message);\n>         else\n> diff --git a/t/t4041-diff-submodule-option.sh b/t/t4041-diff-submodule-option.sh\n> index 4dd4954260..e80472af32 100755\n> --- a/t/t4041-diff-submodule-option.sh\n> +++ b/t/t4041-diff-submodule-option.sh\n> @@ -14,6 +14,24 @@ export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME\n>\n>  . ./test-lib.sh\n>\n> +test_expect_success SHA1 'submodule commit abbreviation uses submodule object database' '\n> +       test_when_finished \"rm -rf collision-super\" &&\n> +       git init -q collision-super &&\n> +       git init -q collision-super/sm1 &&\n> +       printf \"0\\n1\\n2\\n3\\n4\\n5\\n6\\n7\\n8\\n9\\n\\nb1rwzyc3\\n\" >collision-super/sm1/a0blgqsjc &&\n> +       git -C collision-super/sm1 add a0blgqsjc &&\n> +       tree=$(git -C collision-super/sm1 write-tree) &&\n> +       commit1=$(GIT_AUTHOR_DATE=\"1112911993 -0700\" GIT_COMMITTER_DATE=\"1112911993 -0700\" git -C collision-super/sm1 commit-tree \"$tree\" -m a2onsxbvj) &&\n> +       commit2=$(printf \"child\\n\" | GIT_AUTHOR_DATE=\"1112912053 -0700\" GIT_COMMITTER_DATE=\"1112912053 -0700\" git -C collision-super/sm1 commit-tree \"$tree\" -p \"$commit1\") &&\n> +       git -C collision-super/sm1 checkout -q \"$commit2\" &&\n> +       git -C collision-super update-index --add --cacheinfo 160000,\"$commit1\",sm1 &&\n> +       git -C collision-super commit -q -m \"Add submodule\" &&\n> +       git -C collision-super diff --submodule=log >actual &&\n> +       printf \"Submodule sm1 0000000000e..%s:\\n  > child\\n\" \\\n> +               \"$(git -C collision-super/sm1 rev-parse --short \"$commit2\")\" >expected &&\n> +       test_cmp expected actual\n> +'\n> +\n>  # Test non-UTF-8 encoding in case iconv is available.\n>  if test_have_prereq ICONV\n>  then\n>\n> base-commit: 50fe5cc63f9cd6e89b87a2c9ccf96a444f4cfdb7\n> --\n> gitgitgadget\n>\n\n"},{"id":"557045","messageId":"pull.2288.v3.git.1793474657981.gitgitgadget@gmail.com","threadId":"66723","inReplyTo":"pull.2288.git.1793435149942.gitgitgadget@gmail.com","subject":"[PATCH v3] submodule: use the submodule repository to abbreviate commits","fromName":"Srujith A Poojary via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2026-10-31T19:24:17Z","receivedAt":"2026-10-31T19:24:17Z","isPatch":true,"sender":{"key":"name:Srujith A Poojary","avatar":null},"body":"From: Srujith A Poojary <poojarysrujith@gmail.com>\n\nThe commit IDs shown in a submodule diff header belong to the\nsubmodule's object database. However, strbuf_add_unique_abbrev()\nuses the_repository, so it checks the superproject's object\ndatabase when abbreviating those IDs.\n\nUse the submodule repository when it is available, and fall back\nto the repository from the diff options when it is not.\n\nSigned-off-by: Srujith A Poojary <poojarysrujith@gmail.com>\n---\n    [Outreachy PATCH] t4041: use submodule repository for commit\n    abbreviations\n\nPublished-As: https://github.com/gitgitgadget/git/releases/tag/pr-2288%2Fpoojarysrujith%2Fmicroproject-git-libification-v3\nFetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-2288/poojarysrujith/microproject-git-libification-v3\nPull-Request: https://github.com/gitgitgadget/git/pull/2288\n\nRange-diff vs v2:\n\n 1:  3133cd3017 ! 1:  a8c54b9292 Submodule: use the submodule repository to abbreviate commits\n     @@ Metadata\n      Author: Srujith A Poojary <poojarysrujith@gmail.com>\n      \n       ## Commit message ##\n     -    Submodule: use the submodule repository to abbreviate commits\n     +    submodule: use the submodule repository to abbreviate commits\n      \n          The commit IDs shown in a submodule diff header belong to the\n          submodule's object database. However, strbuf_add_unique_abbrev()\n\n\n submodule.c                      |  5 +++--\n t/t4041-diff-submodule-option.sh | 18 ++++++++++++++++++\n 2 files changed, 21 insertions(+), 2 deletions(-)\n\ndiff --git a/submodule.c b/submodule.c\nindex 6fcb606f7e..1302c11ddf 100644\n--- a/submodule.c\n+++ b/submodule.c\n@@ -543,6 +543,7 @@ static void show_submodule_header(struct diff_options *o,\n \t\tstruct commit **left, struct commit **right,\n \t\tstruct commit_list **merge_bases)\n {\n+\tstruct repository *repo = sub ? sub : o->repo;\n \tconst char *message = NULL;\n \tstruct strbuf sb = STRBUF_INIT;\n \tint fast_forward = 0, fast_backward = 0;\n@@ -599,9 +600,9 @@ static void show_submodule_header(struct diff_options *o,\n \n output_header:\n \tstrbuf_addf(&sb, \"Submodule %s \", path);\n-\tstrbuf_add_unique_abbrev(&sb, one, DEFAULT_ABBREV);\n+\tstrbuf_repo_add_unique_abbrev(&sb, repo, one, DEFAULT_ABBREV);\n \tstrbuf_addstr(&sb, (fast_backward || fast_forward) ? \"..\" : \"...\");\n-\tstrbuf_add_unique_abbrev(&sb, two, DEFAULT_ABBREV);\n+\tstrbuf_repo_add_unique_abbrev(&sb, repo, two, DEFAULT_ABBREV);\n \tif (message)\n \t\tstrbuf_addf(&sb, \" %s\\n\", message);\n \telse\ndiff --git a/t/t4041-diff-submodule-option.sh b/t/t4041-diff-submodule-option.sh\nindex 4dd4954260..e80472af32 100755\n--- a/t/t4041-diff-submodule-option.sh\n+++ b/t/t4041-diff-submodule-option.sh\n@@ -14,6 +14,24 @@ export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME\n \n . ./test-lib.sh\n \n+test_expect_success SHA1 'submodule commit abbreviation uses submodule object database' '\n+\ttest_when_finished \"rm -rf collision-super\" &&\n+\tgit init -q collision-super &&\n+\tgit init -q collision-super/sm1 &&\n+\tprintf \"0\\n1\\n2\\n3\\n4\\n5\\n6\\n7\\n8\\n9\\n\\nb1rwzyc3\\n\" >collision-super/sm1/a0blgqsjc &&\n+\tgit -C collision-super/sm1 add a0blgqsjc &&\n+\ttree=$(git -C collision-super/sm1 write-tree) &&\n+\tcommit1=$(GIT_AUTHOR_DATE=\"1112911993 -0700\" GIT_COMMITTER_DATE=\"1112911993 -0700\" git -C collision-super/sm1 commit-tree \"$tree\" -m a2onsxbvj) &&\n+\tcommit2=$(printf \"child\\n\" | GIT_AUTHOR_DATE=\"1112912053 -0700\" GIT_COMMITTER_DATE=\"1112912053 -0700\" git -C collision-super/sm1 commit-tree \"$tree\" -p \"$commit1\") &&\n+\tgit -C collision-super/sm1 checkout -q \"$commit2\" &&\n+\tgit -C collision-super update-index --add --cacheinfo 160000,\"$commit1\",sm1 &&\n+\tgit -C collision-super commit -q -m \"Add submodule\" &&\n+\tgit -C collision-super diff --submodule=log >actual &&\n+\tprintf \"Submodule sm1 0000000000e..%s:\\n  > child\\n\" \\\n+\t\t\"$(git -C collision-super/sm1 rev-parse --short \"$commit2\")\" >expected &&\n+\ttest_cmp expected actual\n+'\n+\n # Test non-UTF-8 encoding in case iconv is available.\n if test_have_prereq ICONV\n then\n\nbase-commit: 50fe5cc63f9cd6e89b87a2c9ccf96a444f4cfdb7\n-- \ngitgitgadget\n\n"},{"id":"557046","messageId":"CABh_KWgi2EVHBdL94J2wByrdjTqggXGa9sj9xoaNTS6ppU3qqg@mail.gmail.com","threadId":"66723","inReplyTo":"CAFpMFfAeMtJ=qTt757aEvMfFyw1nEkB8d07b4wgaTJuQ2tnKiQ@mail.gmail.com","subject":"Re: [PATCH v2] Submodule: use the submodule repository to abbreviate commits","fromName":"Srujith Poojary","fromEmail":"poojarysrujith@gmail.com","sentAt":"2026-10-31T19:37:50Z","receivedAt":"2026-10-31T19:37:50Z","isPatch":true,"sender":{"key":"poojarysrujith@gmail.com","avatar":null},"body":"On Sun, Nov 1, 2026 at 12:39 AM Okhuomon Ajayi\n<okhuomonajayi54@gmail.com> wrote:\n>\n> Hi Srujith,\n>\n> On Sat, Oct 31, 2026 at 7:57 PM Srujith A Poojary via GitGitGadget\n> <gitgitgadget@gmail.com> wrote:\n> > + struct repository *repo = sub ? sub : o->repo;\n>\n> Thanks, v2 looks good to me.\n>\n> > Submodule: use the submodule repository to abbreviate commits\n>\n> One small nit: \"git log --no-merges submodule.c\" shows the area is\n> always written in lowercase (\"submodule:\"), so \"submodule: use the\n> submodule repository to abbreviate commits\" would match.\n>\n> Thanks,\n> Okhuomon\n>\n> On Sat, Oct 31, 2026 at 7:57 PM Srujith A Poojary via GitGitGadget\n> <gitgitgadget@gmail.com> wrote:\n> >\n> > From: Srujith A Poojary <poojarysrujith@gmail.com>\n> >\n> > The commit IDs shown in a submodule diff header belong to the\n> > submodule's object database. However, strbuf_add_unique_abbrev()\n> > uses the_repository, so it checks the superproject's object\n> > database when abbreviating those IDs.\n> >\n> > Use the submodule repository when it is available, and fall back\n> > to the repository from the diff options when it is not.\n> >\n> > Signed-off-by: Srujith A Poojary <poojarysrujith@gmail.com>\n> > ---\n> >     [Outreachy PATCH] t4041: use submodule repository for commit\n> >     abbreviations\n> >\n> > Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-2288%2Fpoojarysrujith%2Fmicroproject-git-libification-v2\n> > Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-2288/poojarysrujith/microproject-git-libification-v2\n> > Pull-Request: https://github.com/gitgitgadget/git/pull/2288\n> >\n> > Range-diff vs v1:\n> >\n> >  1:  7b2af1b46a ! 1:  3133cd3017 [Outreachy PATCH] t4041: use submodule repository for commit abbreviations\n> >      @@ Metadata\n> >       Author: Srujith A Poojary <poojarysrujith@gmail.com>\n> >\n> >        ## Commit message ##\n> >      -    [Outreachy PATCH] t4041: use submodule repository for commit abbreviations\n> >      +    Submodule: use the submodule repository to abbreviate commits\n> >\n> >      -    Use the submodule repository when abbreviating commit IDs in\n> >      -    submodule diff headers, so uniqueness is checked against the\n> >      -    correct object database.\n> >      +    The commit IDs shown in a submodule diff header belong to the\n> >      +    submodule's object database. However, strbuf_add_unique_abbrev()\n> >      +    uses the_repository, so it checks the superproject's object\n> >      +    database when abbreviating those IDs.\n> >      +\n> >      +    Use the submodule repository when it is available, and fall back\n> >      +    to the repository from the diff options when it is not.\n> >\n> >           Signed-off-by: Srujith A Poojary <poojarysrujith@gmail.com>\n> >\n> >        ## submodule.c ##\n> >       @@ submodule.c: static void show_submodule_header(struct diff_options *o,\n> >      +          struct commit **left, struct commit **right,\n> >      +          struct commit_list **merge_bases)\n> >      + {\n> >      ++ struct repository *repo = sub ? sub : o->repo;\n> >      +  const char *message = NULL;\n> >      +  struct strbuf sb = STRBUF_INIT;\n> >      +  int fast_forward = 0, fast_backward = 0;\n> >      +@@ submodule.c: static void show_submodule_header(struct diff_options *o,\n> >\n> >        output_header:\n> >         strbuf_addf(&sb, \"Submodule %s \", path);\n> >       - strbuf_add_unique_abbrev(&sb, one, DEFAULT_ABBREV);\n> >      -+ if (sub)\n> >      -+         strbuf_repo_add_unique_abbrev(&sb, sub, one, DEFAULT_ABBREV);\n> >      -+ else\n> >      -+         strbuf_add_unique_abbrev(&sb, one, DEFAULT_ABBREV);\n> >      ++ strbuf_repo_add_unique_abbrev(&sb, repo, one, DEFAULT_ABBREV);\n> >         strbuf_addstr(&sb, (fast_backward || fast_forward) ? \"..\" : \"...\");\n> >       - strbuf_add_unique_abbrev(&sb, two, DEFAULT_ABBREV);\n> >      -+ if (sub)\n> >      -+         strbuf_repo_add_unique_abbrev(&sb, sub, two, DEFAULT_ABBREV);\n> >      -+ else\n> >      -+         strbuf_add_unique_abbrev(&sb, two, DEFAULT_ABBREV);\n> >      ++ strbuf_repo_add_unique_abbrev(&sb, repo, two, DEFAULT_ABBREV);\n> >         if (message)\n> >                 strbuf_addf(&sb, \" %s\\n\", message);\n> >         else\n> >\n> >\n> >  submodule.c                      |  5 +++--\n> >  t/t4041-diff-submodule-option.sh | 18 ++++++++++++++++++\n> >  2 files changed, 21 insertions(+), 2 deletions(-)\n> >\n> > diff --git a/submodule.c b/submodule.c\n> > index 6fcb606f7e..1302c11ddf 100644\n> > --- a/submodule.c\n> > +++ b/submodule.c\n> > @@ -543,6 +543,7 @@ static void show_submodule_header(struct diff_options *o,\n> >                 struct commit **left, struct commit **right,\n> >                 struct commit_list **merge_bases)\n> >  {\n> > +       struct repository *repo = sub ? sub : o->repo;\n> >         const char *message = NULL;\n> >         struct strbuf sb = STRBUF_INIT;\n> >         int fast_forward = 0, fast_backward = 0;\n> > @@ -599,9 +600,9 @@ static void show_submodule_header(struct diff_options *o,\n> >\n> >  output_header:\n> >         strbuf_addf(&sb, \"Submodule %s \", path);\n> > -       strbuf_add_unique_abbrev(&sb, one, DEFAULT_ABBREV);\n> > +       strbuf_repo_add_unique_abbrev(&sb, repo, one, DEFAULT_ABBREV);\n> >         strbuf_addstr(&sb, (fast_backward || fast_forward) ? \"..\" : \"...\");\n> > -       strbuf_add_unique_abbrev(&sb, two, DEFAULT_ABBREV);\n> > +       strbuf_repo_add_unique_abbrev(&sb, repo, two, DEFAULT_ABBREV);\n> >         if (message)\n> >                 strbuf_addf(&sb, \" %s\\n\", message);\n> >         else\n> > diff --git a/t/t4041-diff-submodule-option.sh b/t/t4041-diff-submodule-option.sh\n> > index 4dd4954260..e80472af32 100755\n> > --- a/t/t4041-diff-submodule-option.sh\n> > +++ b/t/t4041-diff-submodule-option.sh\n> > @@ -14,6 +14,24 @@ export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME\n> >\n> >  . ./test-lib.sh\n> >\n> > +test_expect_success SHA1 'submodule commit abbreviation uses submodule object database' '\n> > +       test_when_finished \"rm -rf collision-super\" &&\n> > +       git init -q collision-super &&\n> > +       git init -q collision-super/sm1 &&\n> > +       printf \"0\\n1\\n2\\n3\\n4\\n5\\n6\\n7\\n8\\n9\\n\\nb1rwzyc3\\n\" >collision-super/sm1/a0blgqsjc &&\n> > +       git -C collision-super/sm1 add a0blgqsjc &&\n> > +       tree=$(git -C collision-super/sm1 write-tree) &&\n> > +       commit1=$(GIT_AUTHOR_DATE=\"1112911993 -0700\" GIT_COMMITTER_DATE=\"1112911993 -0700\" git -C collision-super/sm1 commit-tree \"$tree\" -m a2onsxbvj) &&\n> > +       commit2=$(printf \"child\\n\" | GIT_AUTHOR_DATE=\"1112912053 -0700\" GIT_COMMITTER_DATE=\"1112912053 -0700\" git -C collision-super/sm1 commit-tree \"$tree\" -p \"$commit1\") &&\n> > +       git -C collision-super/sm1 checkout -q \"$commit2\" &&\n> > +       git -C collision-super update-index --add --cacheinfo 160000,\"$commit1\",sm1 &&\n> > +       git -C collision-super commit -q -m \"Add submodule\" &&\n> > +       git -C collision-super diff --submodule=log >actual &&\n> > +       printf \"Submodule sm1 0000000000e..%s:\\n  > child\\n\" \\\n> > +               \"$(git -C collision-super/sm1 rev-parse --short \"$commit2\")\" >expected &&\n> > +       test_cmp expected actual\n> > +'\n> > +\n> >  # Test non-UTF-8 encoding in case iconv is available.\n> >  if test_have_prereq ICONV\n> >  then\n> >\n> > base-commit: 50fe5cc63f9cd6e89b87a2c9ccf96a444f4cfdb7\n> > --\n> > gitgitgadget\n\nHi Okhuomon,\n\nThanks for pointing that out. I've corrected the subject to use\nlowercase `submodule` and submitted v3.\n\nRegards,\nSrujith\n> >\n\n"},{"id":"557094","messageId":"xmqqecd4z0mx.fsf@gitster.g","threadId":"66723","inReplyTo":"pull.2288.v3.git.1793474657981.gitgitgadget@gmail.com","subject":"Re: [PATCH v3] submodule: use the submodule repository to abbreviate commits","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2026-11-01T21:45:42Z","receivedAt":"2026-11-01T21:45:42Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"Srujith A Poojary via GitGitGadget\" <gitgitgadget@gmail.com>\nwrites:\n\n> From: Srujith A Poojary <poojarysrujith@gmail.com>\n>\n> The commit IDs shown in a submodule diff header belong to the\n> submodule's object database. However, strbuf_add_unique_abbrev()\n> uses the_repository, so it checks the superproject's object\n> database when abbreviating those IDs.\n>\n> Use the submodule repository when it is available, and fall back\n> to the repository from the diff options when it is not.\n\nWhile the fallback behaviour does not make much sense (the commit\nobject recorded in gitlink is not expected to be found in the\nsuperproject's repository, which is the reason why you are adding\nthis fix in the first place), it would mean that for unpopulated\nsubmodules for which you haven't run \"git submodule init\", the\nbehaviour would stay the ame as before.\n\n> diff --git a/submodule.c b/submodule.c\n> index 6fcb606f7e..1302c11ddf 100644\n> --- a/submodule.c\n> +++ b/submodule.c\n> @@ -543,6 +543,7 @@ static void show_submodule_header(struct diff_options *o,\n>  \t\tstruct commit **left, struct commit **right,\n>  \t\tstruct commit_list **merge_bases)\n>  {\n> +\tstruct repository *repo = sub ? sub : o->repo;\n>  \tconst char *message = NULL;\n>  \tstruct strbuf sb = STRBUF_INIT;\n>  \tint fast_forward = 0, fast_backward = 0;\n> @@ -599,9 +600,9 @@ static void show_submodule_header(struct diff_options *o,\n>  \n>  output_header:\n>  \tstrbuf_addf(&sb, \"Submodule %s \", path);\n> -\tstrbuf_add_unique_abbrev(&sb, one, DEFAULT_ABBREV);\n> +\tstrbuf_repo_add_unique_abbrev(&sb, repo, one, DEFAULT_ABBREV);\n>  \tstrbuf_addstr(&sb, (fast_backward || fast_forward) ? \"..\" : \"...\");\n> -\tstrbuf_add_unique_abbrev(&sb, two, DEFAULT_ABBREV);\n> +\tstrbuf_repo_add_unique_abbrev(&sb, repo, two, DEFAULT_ABBREV);\n>  \tif (message)\n>  \t\tstrbuf_addf(&sb, \" %s\\n\", message);\n>  \telse\n\nQuite straightforward.\n\n> +test_expect_success SHA1 'submodule commit abbreviation uses submodule object database' '\n\nHmph.  I wonder if there is a way to use the test_oid_cache\nfacility to allow test with both SHA-1 and SHA-256 hashes?\n\nWill queue.\n\nThanks.\n\n"},{"id":"557226","messageId":"pull.2288.v4.git.1793648430.gitgitgadget@gmail.com","threadId":"66723","inReplyTo":"pull.2288.git.1793435149942.gitgitgadget@gmail.com","subject":"[PATCH v4 0/2] [Outreachy PATCH] t4041: use submodule repository for commit abbreviations","fromName":"Srujith A Poojary via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2026-11-02T19:40:28Z","receivedAt":"2026-11-02T19:40:28Z","isPatch":true,"sender":{"key":"name:Srujith A Poojary","avatar":null},"body":"Srujith A Poojary (2):\n  submodule: use the submodule repository to abbreviate commits\n  t4041: test SHA-256 submodule abbreviations\n\n submodule.c                      |  5 +++--\n t/t4041-diff-submodule-option.sh | 23 +++++++++++++++++++++++\n 2 files changed, 26 insertions(+), 2 deletions(-)\n\n\nbase-commit: 50fe5cc63f9cd6e89b87a2c9ccf96a444f4cfdb7\nPublished-As: https://github.com/gitgitgadget/git/releases/tag/pr-2288%2Fpoojarysrujith%2Fmicroproject-git-libification-v4\nFetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-2288/poojarysrujith/microproject-git-libification-v4\nPull-Request: https://github.com/gitgitgadget/git/pull/2288\n\nRange-diff vs v3:\n\n 1:  a8c54b9292 = 1:  a8c54b9292 submodule: use the submodule repository to abbreviate commits\n -:  ---------- > 2:  99a1234544 t4041: test SHA-256 submodule abbreviations\n\n-- \ngitgitgadget\n\n"},{"id":"557227","messageId":"a8c54b929255679ebd02ca06ef1f58de87448064.1793648430.git.gitgitgadget@gmail.com","threadId":"66723","inReplyTo":"pull.2288.v4.git.1793648430.gitgitgadget@gmail.com","subject":"[PATCH v4 1/2] submodule: use the submodule repository to abbreviate commits","fromName":"Srujith A Poojary via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2026-11-02T19:40:29Z","receivedAt":"2026-11-02T19:40:29Z","isPatch":true,"sender":{"key":"name:Srujith A Poojary","avatar":null},"body":"From: Srujith A Poojary <poojarysrujith@gmail.com>\n\nThe commit IDs shown in a submodule diff header belong to the\nsubmodule's object database. However, strbuf_add_unique_abbrev()\nuses the_repository, so it checks the superproject's object\ndatabase when abbreviating those IDs.\n\nUse the submodule repository when it is available, and fall back\nto the repository from the diff options when it is not.\n\nSigned-off-by: Srujith A Poojary <poojarysrujith@gmail.com>\n---\n submodule.c                      |  5 +++--\n t/t4041-diff-submodule-option.sh | 18 ++++++++++++++++++\n 2 files changed, 21 insertions(+), 2 deletions(-)\n\ndiff --git a/submodule.c b/submodule.c\nindex 6fcb606f7e..1302c11ddf 100644\n--- a/submodule.c\n+++ b/submodule.c\n@@ -543,6 +543,7 @@ static void show_submodule_header(struct diff_options *o,\n \t\tstruct commit **left, struct commit **right,\n \t\tstruct commit_list **merge_bases)\n {\n+\tstruct repository *repo = sub ? sub : o->repo;\n \tconst char *message = NULL;\n \tstruct strbuf sb = STRBUF_INIT;\n \tint fast_forward = 0, fast_backward = 0;\n@@ -599,9 +600,9 @@ static void show_submodule_header(struct diff_options *o,\n \n output_header:\n \tstrbuf_addf(&sb, \"Submodule %s \", path);\n-\tstrbuf_add_unique_abbrev(&sb, one, DEFAULT_ABBREV);\n+\tstrbuf_repo_add_unique_abbrev(&sb, repo, one, DEFAULT_ABBREV);\n \tstrbuf_addstr(&sb, (fast_backward || fast_forward) ? \"..\" : \"...\");\n-\tstrbuf_add_unique_abbrev(&sb, two, DEFAULT_ABBREV);\n+\tstrbuf_repo_add_unique_abbrev(&sb, repo, two, DEFAULT_ABBREV);\n \tif (message)\n \t\tstrbuf_addf(&sb, \" %s\\n\", message);\n \telse\ndiff --git a/t/t4041-diff-submodule-option.sh b/t/t4041-diff-submodule-option.sh\nindex 4dd4954260..e80472af32 100755\n--- a/t/t4041-diff-submodule-option.sh\n+++ b/t/t4041-diff-submodule-option.sh\n@@ -14,6 +14,24 @@ export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME\n \n . ./test-lib.sh\n \n+test_expect_success SHA1 'submodule commit abbreviation uses submodule object database' '\n+\ttest_when_finished \"rm -rf collision-super\" &&\n+\tgit init -q collision-super &&\n+\tgit init -q collision-super/sm1 &&\n+\tprintf \"0\\n1\\n2\\n3\\n4\\n5\\n6\\n7\\n8\\n9\\n\\nb1rwzyc3\\n\" >collision-super/sm1/a0blgqsjc &&\n+\tgit -C collision-super/sm1 add a0blgqsjc &&\n+\ttree=$(git -C collision-super/sm1 write-tree) &&\n+\tcommit1=$(GIT_AUTHOR_DATE=\"1112911993 -0700\" GIT_COMMITTER_DATE=\"1112911993 -0700\" git -C collision-super/sm1 commit-tree \"$tree\" -m a2onsxbvj) &&\n+\tcommit2=$(printf \"child\\n\" | GIT_AUTHOR_DATE=\"1112912053 -0700\" GIT_COMMITTER_DATE=\"1112912053 -0700\" git -C collision-super/sm1 commit-tree \"$tree\" -p \"$commit1\") &&\n+\tgit -C collision-super/sm1 checkout -q \"$commit2\" &&\n+\tgit -C collision-super update-index --add --cacheinfo 160000,\"$commit1\",sm1 &&\n+\tgit -C collision-super commit -q -m \"Add submodule\" &&\n+\tgit -C collision-super diff --submodule=log >actual &&\n+\tprintf \"Submodule sm1 0000000000e..%s:\\n  > child\\n\" \\\n+\t\t\"$(git -C collision-super/sm1 rev-parse --short \"$commit2\")\" >expected &&\n+\ttest_cmp expected actual\n+'\n+\n # Test non-UTF-8 encoding in case iconv is available.\n if test_have_prereq ICONV\n then\n-- \ngitgitgadget\n\n\n"},{"id":"557228","messageId":"99a1234544840e63e6f3dcf3c6beae3ba02af84b.1793648430.git.gitgitgadget@gmail.com","threadId":"66723","inReplyTo":"pull.2288.v4.git.1793648430.gitgitgadget@gmail.com","subject":"[PATCH v4 2/2] t4041: test SHA-256 submodule abbreviations","fromName":"Srujith A Poojary via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2026-11-02T19:40:30Z","receivedAt":"2026-11-02T19:40:30Z","isPatch":true,"sender":{"key":"name:Srujith A Poojary","avatar":null},"body":"From: Srujith A Poojary <poojarysrujith@gmail.com>\n\nThe expected abbreviation for a submodule commit depends on the\nrepository's hash algorithm. Use test_oid_cache to provide the\nexpected value for each algorithm and remove the SHA1 prerequisite\nso this test runs with both SHA-1 and SHA-256.\n\nSigned-off-by: Srujith A Poojary <poojarysrujith@gmail.com>\n---\n t/t4041-diff-submodule-option.sh | 9 +++++++--\n 1 file changed, 7 insertions(+), 2 deletions(-)\n\ndiff --git a/t/t4041-diff-submodule-option.sh b/t/t4041-diff-submodule-option.sh\nindex e80472af32..4539d6bba5 100755\n--- a/t/t4041-diff-submodule-option.sh\n+++ b/t/t4041-diff-submodule-option.sh\n@@ -14,7 +14,11 @@ export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME\n \n . ./test-lib.sh\n \n-test_expect_success SHA1 'submodule commit abbreviation uses submodule object database' '\n+test_expect_success 'submodule commit abbreviation uses submodule object database' '\n+\ttest_oid_cache <<-EOF &&\n+\tsubmodule_commit1_abbrev sha1:0000000000e\n+\tsubmodule_commit1_abbrev sha256:24c81a5\n+\tEOF\n \ttest_when_finished \"rm -rf collision-super\" &&\n \tgit init -q collision-super &&\n \tgit init -q collision-super/sm1 &&\n@@ -27,7 +31,8 @@ test_expect_success SHA1 'submodule commit abbreviation uses submodule object da\n \tgit -C collision-super update-index --add --cacheinfo 160000,\"$commit1\",sm1 &&\n \tgit -C collision-super commit -q -m \"Add submodule\" &&\n \tgit -C collision-super diff --submodule=log >actual &&\n-\tprintf \"Submodule sm1 0000000000e..%s:\\n  > child\\n\" \\\n+\tprintf \"Submodule sm1 %s..%s:\\n  > child\\n\" \\\n+\t\t\"$(test_oid submodule_commit1_abbrev)\" \\\n \t\t\"$(git -C collision-super/sm1 rev-parse --short \"$commit2\")\" >expected &&\n \ttest_cmp expected actual\n '\n-- \ngitgitgadget\n\n"},{"id":"557230","messageId":"CABh_KWhHP0bxE0PAGvn-1=DNSoLUCmr_Aq6n-p3wC+VFXkCjZA@mail.gmail.com","threadId":"66723","inReplyTo":"a8c54b929255679ebd02ca06ef1f58de87448064.1793648430.git.gitgitgadget@gmail.com","subject":"Re: [PATCH v4 1/2] submodule: use the submodule repository to abbreviate commits","fromName":"Srujith Poojary","fromEmail":"poojarysrujith@gmail.com","sentAt":"2026-11-02T19:49:42Z","receivedAt":"2026-11-02T19:49:42Z","isPatch":true,"sender":{"key":"poojarysrujith@gmail.com","avatar":null},"body":"On Tue, Nov 3, 2026 at 1:10 AM Srujith A Poojary via GitGitGadget\n<gitgitgadget@gmail.com> wrote:\n>\n> From: Srujith A Poojary <poojarysrujith@gmail.com>\n>\n> The commit IDs shown in a submodule diff header belong to the\n> submodule's object database. However, strbuf_add_unique_abbrev()\n> uses the_repository, so it checks the superproject's object\n> database when abbreviating those IDs.\n>\n> Use the submodule repository when it is available, and fall back\n> to the repository from the diff options when it is not.\n>\n> Signed-off-by: Srujith A Poojary <poojarysrujith@gmail.com>\n> ---\n>  submodule.c                      |  5 +++--\n>  t/t4041-diff-submodule-option.sh | 18 ++++++++++++++++++\n>  2 files changed, 21 insertions(+), 2 deletions(-)\n>\n> diff --git a/submodule.c b/submodule.c\n> index 6fcb606f7e..1302c11ddf 100644\n> --- a/submodule.c\n> +++ b/submodule.c\n> @@ -543,6 +543,7 @@ static void show_submodule_header(struct diff_options *o,\n>                 struct commit **left, struct commit **right,\n>                 struct commit_list **merge_bases)\n>  {\n> +       struct repository *repo = sub ? sub : o->repo;\n>         const char *message = NULL;\n>         struct strbuf sb = STRBUF_INIT;\n>         int fast_forward = 0, fast_backward = 0;\n> @@ -599,9 +600,9 @@ static void show_submodule_header(struct diff_options *o,\n>\n>  output_header:\n>         strbuf_addf(&sb, \"Submodule %s \", path);\n> -       strbuf_add_unique_abbrev(&sb, one, DEFAULT_ABBREV);\n> +       strbuf_repo_add_unique_abbrev(&sb, repo, one, DEFAULT_ABBREV);\n>         strbuf_addstr(&sb, (fast_backward || fast_forward) ? \"..\" : \"...\");\n> -       strbuf_add_unique_abbrev(&sb, two, DEFAULT_ABBREV);\n> +       strbuf_repo_add_unique_abbrev(&sb, repo, two, DEFAULT_ABBREV);\n>         if (message)\n>                 strbuf_addf(&sb, \" %s\\n\", message);\n>         else\n> diff --git a/t/t4041-diff-submodule-option.sh b/t/t4041-diff-submodule-option.sh\n> index 4dd4954260..e80472af32 100755\n> --- a/t/t4041-diff-submodule-option.sh\n> +++ b/t/t4041-diff-submodule-option.sh\n> @@ -14,6 +14,24 @@ export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME\n>\n>  . ./test-lib.sh\n>\n> +test_expect_success SHA1 'submodule commit abbreviation uses submodule object database' '\n> +       test_when_finished \"rm -rf collision-super\" &&\n> +       git init -q collision-super &&\n> +       git init -q collision-super/sm1 &&\n> +       printf \"0\\n1\\n2\\n3\\n4\\n5\\n6\\n7\\n8\\n9\\n\\nb1rwzyc3\\n\" >collision-super/sm1/a0blgqsjc &&\n> +       git -C collision-super/sm1 add a0blgqsjc &&\n> +       tree=$(git -C collision-super/sm1 write-tree) &&\n> +       commit1=$(GIT_AUTHOR_DATE=\"1112911993 -0700\" GIT_COMMITTER_DATE=\"1112911993 -0700\" git -C collision-super/sm1 commit-tree \"$tree\" -m a2onsxbvj) &&\n> +       commit2=$(printf \"child\\n\" | GIT_AUTHOR_DATE=\"1112912053 -0700\" GIT_COMMITTER_DATE=\"1112912053 -0700\" git -C collision-super/sm1 commit-tree \"$tree\" -p \"$commit1\") &&\n> +       git -C collision-super/sm1 checkout -q \"$commit2\" &&\n> +       git -C collision-super update-index --add --cacheinfo 160000,\"$commit1\",sm1 &&\n> +       git -C collision-super commit -q -m \"Add submodule\" &&\n> +       git -C collision-super diff --submodule=log >actual &&\n> +       printf \"Submodule sm1 0000000000e..%s:\\n  > child\\n\" \\\n> +               \"$(git -C collision-super/sm1 rev-parse --short \"$commit2\")\" >expected &&\n> +       test_cmp expected actual\n> +'\n> +\n>  # Test non-UTF-8 encoding in case iconv is available.\n>  if test_have_prereq ICONV\n>  then\n> --\n> gitgitgadget\n>\nHi Junio,\n\nThanks for the suggestion.\n\nI've updated the t4041 test to use `test_oid_cache` with separate\nexpected abbreviations for SHA-1 and SHA-256. I've also removed the\nSHA1-only prerequisite so that the test runs with both hash\nalgorithms.\n\nI tested the updated test script using both configurations:\n\n- SHA-1: all 48 tests passed.\n- SHA-256: all 48 tests passed.\n\nI've updated the commit message, added the Signed-off-by trailer, and\nsubmitted the revised v4 patch series.\n\nThe updated patch series is available here:\nhttps://lore.kernel.org/git/pull.2288.v4.git.1793648490.gitgitgadget@gmail.com/\n\nThanks for the suggestion and review.\n\nRegards,\nSrujith\n\n"},{"id":"557341","messageId":"xmqqbj85akqj.fsf@gitster.g","threadId":"66723","inReplyTo":"pull.2288.v4.git.1793648430.gitgitgadget@gmail.com","subject":"Re: [PATCH v4 0/2] [Outreachy PATCH] t4041: use submodule repository for commit abbreviations","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2026-11-03T17:27:32Z","receivedAt":"2026-11-03T17:27:32Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"Srujith A Poojary via GitGitGadget\" <gitgitgadget@gmail.com>\nwrites:\n\n> Srujith A Poojary (2):\n>   submodule: use the submodule repository to abbreviate commits\n>   t4041: test SHA-256 submodule abbreviations\n\nIf you are sending a cover letter, you are expected to summarize the\nchanges since the previous iteration(s) in it, so that those who are\njoining the discussion in the middle can tell the history behind the\ncurrent iteration.\n\n>  submodule.c                      |  5 +++--\n>  t/t4041-diff-submodule-option.sh | 23 +++++++++++++++++++++++\n>  2 files changed, 26 insertions(+), 2 deletions(-)\n>\n>\n> base-commit: 50fe5cc63f9cd6e89b87a2c9ccf96a444f4cfdb7\n> Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-2288%2Fpoojarysrujith%2Fmicroproject-git-libification-v4\n> Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-2288/poojarysrujith/microproject-git-libification-v4\n> Pull-Request: https://github.com/gitgitgadget/git/pull/2288\n>\n> Range-diff vs v3:\n>\n>  1:  a8c54b9292 = 1:  a8c54b9292 submodule: use the submodule repository to abbreviate commits\n>  -:  ---------- > 2:  99a1234544 t4041: test SHA-256 submodule abbreviations\n\n"},{"id":"557343","messageId":"xmqq7bitakkm.fsf@gitster.g","threadId":"66723","inReplyTo":"99a1234544840e63e6f3dcf3c6beae3ba02af84b.1793648430.git.gitgitgadget@gmail.com","subject":"Re: [PATCH v4 2/2] t4041: test SHA-256 submodule abbreviations","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2026-11-03T17:31:05Z","receivedAt":"2026-11-03T17:31:05Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"Srujith A Poojary via GitGitGadget\" <gitgitgadget@gmail.com>\nwrites:\n\n> From: Srujith A Poojary <poojarysrujith@gmail.com>\n>\n> The expected abbreviation for a submodule commit depends on the\n> repository's hash algorithm. Use test_oid_cache to provide the\n> expected value for each algorithm and remove the SHA1 prerequisite\n> so this test runs with both SHA-1 and SHA-256.\n>\n> Signed-off-by: Srujith A Poojary <poojarysrujith@gmail.com>\n> ---\n>  t/t4041-diff-submodule-option.sh | 9 +++++++--\n>  1 file changed, 7 insertions(+), 2 deletions(-)\n\nIt is strange to test SHA-1 in 1/2 and add test for SHA-256 as if an\nafterthought in 2/2.  Shouldn't all of these come in a single patch?\n\nThe change to add the second hash algorithm support is surprisingly\nclean, primarily thanks to how test_oid* support was done long ago.\n\n> diff --git a/t/t4041-diff-submodule-option.sh b/t/t4041-diff-submodule-option.sh\n> index e80472af32..4539d6bba5 100755\n> --- a/t/t4041-diff-submodule-option.sh\n> +++ b/t/t4041-diff-submodule-option.sh\n> @@ -14,7 +14,11 @@ export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME\n>  \n>  . ./test-lib.sh\n>  \n> -test_expect_success SHA1 'submodule commit abbreviation uses submodule object database' '\n> +test_expect_success 'submodule commit abbreviation uses submodule object database' '\n> +\ttest_oid_cache <<-EOF &&\n> +\tsubmodule_commit1_abbrev sha1:0000000000e\n> +\tsubmodule_commit1_abbrev sha256:24c81a5\n> +\tEOF\n>  \ttest_when_finished \"rm -rf collision-super\" &&\n>  \tgit init -q collision-super &&\n>  \tgit init -q collision-super/sm1 &&\n> @@ -27,7 +31,8 @@ test_expect_success SHA1 'submodule commit abbreviation uses submodule object da\n>  \tgit -C collision-super update-index --add --cacheinfo 160000,\"$commit1\",sm1 &&\n>  \tgit -C collision-super commit -q -m \"Add submodule\" &&\n>  \tgit -C collision-super diff --submodule=log >actual &&\n> -\tprintf \"Submodule sm1 0000000000e..%s:\\n  > child\\n\" \\\n> +\tprintf \"Submodule sm1 %s..%s:\\n  > child\\n\" \\\n> +\t\t\"$(test_oid submodule_commit1_abbrev)\" \\\n>  \t\t\"$(git -C collision-super/sm1 rev-parse --short \"$commit2\")\" >expected &&\n>  \ttest_cmp expected actual\n>  '\n\n"},{"id":"557399","messageId":"pull.2288.v5.git.1793763781129.gitgitgadget@gmail.com","threadId":"66723","inReplyTo":"pull.2288.git.1793435149942.gitgitgadget@gmail.com","subject":"[PATCH v5] submodule: use the submodule repository to abbreviate commits","fromName":"Srujith A Poojary via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2026-11-04T03:43:01Z","receivedAt":"2026-11-04T03:43:01Z","isPatch":true,"sender":{"key":"name:Srujith A Poojary","avatar":null},"body":"From: Srujith A Poojary <poojarysrujith@gmail.com>\n\nThe commit IDs shown in a submodule diff header belong to the\nsubmodule's object database. However, strbuf_add_unique_abbrev()\nuses the_repository, so it checks the superproject's object\ndatabase when abbreviating those IDs.\n\nUse the submodule repository when it is available, and fall back\nto the repository from the diff options when it is not.\n\nThe expected abbreviation for a submodule commit depends on the\nrepository's hash algorithm. Use test_oid_cache to provide the\nexpected value for each algorithm and remove the SHA1 prerequisite\nso this test runs with both SHA-1 and SHA-256.\n\nSigned-off-by: Srujith A Poojary <poojarysrujith@gmail.com>\n---\n    [Outreachy PATCH] t4041: use submodule repository for commit\n    abbreviations\n\nPublished-As: https://github.com/gitgitgadget/git/releases/tag/pr-2288%2Fpoojarysrujith%2Fmicroproject-git-libification-v5\nFetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-2288/poojarysrujith/microproject-git-libification-v5\nPull-Request: https://github.com/gitgitgadget/git/pull/2288\n\nRange-diff vs v4:\n\n 1:  a8c54b9292 ! 1:  f94aa2476f submodule: use the submodule repository to abbreviate commits\n     @@ Commit message\n          Use the submodule repository when it is available, and fall back\n          to the repository from the diff options when it is not.\n      \n     +    The expected abbreviation for a submodule commit depends on the\n     +    repository's hash algorithm. Use test_oid_cache to provide the\n     +    expected value for each algorithm and remove the SHA1 prerequisite\n     +    so this test runs with both SHA-1 and SHA-256.\n     +\n          Signed-off-by: Srujith A Poojary <poojarysrujith@gmail.com>\n      \n       ## submodule.c ##\n     @@ t/t4041-diff-submodule-option.sh: export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME\n       \n       . ./test-lib.sh\n       \n     -+test_expect_success SHA1 'submodule commit abbreviation uses submodule object database' '\n     ++test_expect_success 'submodule commit abbreviation uses submodule object database' '\n     ++\ttest_oid_cache <<-EOF &&\n     ++\tsubmodule_commit1_abbrev sha1:0000000000e\n     ++\tsubmodule_commit1_abbrev sha256:24c81a5\n     ++\tEOF\n      +\ttest_when_finished \"rm -rf collision-super\" &&\n      +\tgit init -q collision-super &&\n      +\tgit init -q collision-super/sm1 &&\n     @@ t/t4041-diff-submodule-option.sh: export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME\n      +\tgit -C collision-super update-index --add --cacheinfo 160000,\"$commit1\",sm1 &&\n      +\tgit -C collision-super commit -q -m \"Add submodule\" &&\n      +\tgit -C collision-super diff --submodule=log >actual &&\n     -+\tprintf \"Submodule sm1 0000000000e..%s:\\n  > child\\n\" \\\n     ++\tprintf \"Submodule sm1 %s..%s:\\n  > child\\n\" \\\n     ++\t\t\"$(test_oid submodule_commit1_abbrev)\" \\\n      +\t\t\"$(git -C collision-super/sm1 rev-parse --short \"$commit2\")\" >expected &&\n      +\ttest_cmp expected actual\n      +'\n 2:  99a1234544 < -:  ---------- t4041: test SHA-256 submodule abbreviations\n\n\n submodule.c                      |  5 +++--\n t/t4041-diff-submodule-option.sh | 23 +++++++++++++++++++++++\n 2 files changed, 26 insertions(+), 2 deletions(-)\n\ndiff --git a/submodule.c b/submodule.c\nindex 6fcb606f7e..1302c11ddf 100644\n--- a/submodule.c\n+++ b/submodule.c\n@@ -543,6 +543,7 @@ static void show_submodule_header(struct diff_options *o,\n \t\tstruct commit **left, struct commit **right,\n \t\tstruct commit_list **merge_bases)\n {\n+\tstruct repository *repo = sub ? sub : o->repo;\n \tconst char *message = NULL;\n \tstruct strbuf sb = STRBUF_INIT;\n \tint fast_forward = 0, fast_backward = 0;\n@@ -599,9 +600,9 @@ static void show_submodule_header(struct diff_options *o,\n \n output_header:\n \tstrbuf_addf(&sb, \"Submodule %s \", path);\n-\tstrbuf_add_unique_abbrev(&sb, one, DEFAULT_ABBREV);\n+\tstrbuf_repo_add_unique_abbrev(&sb, repo, one, DEFAULT_ABBREV);\n \tstrbuf_addstr(&sb, (fast_backward || fast_forward) ? \"..\" : \"...\");\n-\tstrbuf_add_unique_abbrev(&sb, two, DEFAULT_ABBREV);\n+\tstrbuf_repo_add_unique_abbrev(&sb, repo, two, DEFAULT_ABBREV);\n \tif (message)\n \t\tstrbuf_addf(&sb, \" %s\\n\", message);\n \telse\ndiff --git a/t/t4041-diff-submodule-option.sh b/t/t4041-diff-submodule-option.sh\nindex 4dd4954260..4539d6bba5 100755\n--- a/t/t4041-diff-submodule-option.sh\n+++ b/t/t4041-diff-submodule-option.sh\n@@ -14,6 +14,29 @@ export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME\n \n . ./test-lib.sh\n \n+test_expect_success 'submodule commit abbreviation uses submodule object database' '\n+\ttest_oid_cache <<-EOF &&\n+\tsubmodule_commit1_abbrev sha1:0000000000e\n+\tsubmodule_commit1_abbrev sha256:24c81a5\n+\tEOF\n+\ttest_when_finished \"rm -rf collision-super\" &&\n+\tgit init -q collision-super &&\n+\tgit init -q collision-super/sm1 &&\n+\tprintf \"0\\n1\\n2\\n3\\n4\\n5\\n6\\n7\\n8\\n9\\n\\nb1rwzyc3\\n\" >collision-super/sm1/a0blgqsjc &&\n+\tgit -C collision-super/sm1 add a0blgqsjc &&\n+\ttree=$(git -C collision-super/sm1 write-tree) &&\n+\tcommit1=$(GIT_AUTHOR_DATE=\"1112911993 -0700\" GIT_COMMITTER_DATE=\"1112911993 -0700\" git -C collision-super/sm1 commit-tree \"$tree\" -m a2onsxbvj) &&\n+\tcommit2=$(printf \"child\\n\" | GIT_AUTHOR_DATE=\"1112912053 -0700\" GIT_COMMITTER_DATE=\"1112912053 -0700\" git -C collision-super/sm1 commit-tree \"$tree\" -p \"$commit1\") &&\n+\tgit -C collision-super/sm1 checkout -q \"$commit2\" &&\n+\tgit -C collision-super update-index --add --cacheinfo 160000,\"$commit1\",sm1 &&\n+\tgit -C collision-super commit -q -m \"Add submodule\" &&\n+\tgit -C collision-super diff --submodule=log >actual &&\n+\tprintf \"Submodule sm1 %s..%s:\\n  > child\\n\" \\\n+\t\t\"$(test_oid submodule_commit1_abbrev)\" \\\n+\t\t\"$(git -C collision-super/sm1 rev-parse --short \"$commit2\")\" >expected &&\n+\ttest_cmp expected actual\n+'\n+\n # Test non-UTF-8 encoding in case iconv is available.\n if test_have_prereq ICONV\n then\n\nbase-commit: 50fe5cc63f9cd6e89b87a2c9ccf96a444f4cfdb7\n-- \ngitgitgadget\n\n"},{"id":"557400","messageId":"CABh_KWg9bLLc64_UORHfLY3vhVSTfzN585fcQ9d6w8cZocGwvA@mail.gmail.com","threadId":"66723","inReplyTo":"xmqq7bitakkm.fsf@gitster.g","subject":"Re: [PATCH v4 2/2] t4041: test SHA-256 submodule abbreviations","fromName":"Srujith Poojary","fromEmail":"poojarysrujith@gmail.com","sentAt":"2026-11-04T03:58:40Z","receivedAt":"2026-11-04T03:58:40Z","isPatch":true,"sender":{"key":"poojarysrujith@gmail.com","avatar":null},"body":"On Tue, Nov 3, 2026 at 11:01 PM Junio C Hamano <gitster@pobox.com> wrote:\n>\n> \"Srujith A Poojary via GitGitGadget\" <gitgitgadget@gmail.com>\n> writes:\n>\n> > From: Srujith A Poojary <poojarysrujith@gmail.com>\n> >\n> > The expected abbreviation for a submodule commit depends on the\n> > repository's hash algorithm. Use test_oid_cache to provide the\n> > expected value for each algorithm and remove the SHA1 prerequisite\n> > so this test runs with both SHA-1 and SHA-256.\n> >\n> > Signed-off-by: Srujith A Poojary <poojarysrujith@gmail.com>\n> > ---\n> >  t/t4041-diff-submodule-option.sh | 9 +++++++--\n> >  1 file changed, 7 insertions(+), 2 deletions(-)\n>\n> It is strange to test SHA-1 in 1/2 and add test for SHA-256 as if an\n> afterthought in 2/2.  Shouldn't all of these come in a single patch?\n>\n> The change to add the second hash algorithm support is surprisingly\n> clean, primarily thanks to how test_oid* support was done long ago.\n>\n> > diff --git a/t/t4041-diff-submodule-option.sh b/t/t4041-diff-submodule-option.sh\n> > index e80472af32..4539d6bba5 100755\n> > --- a/t/t4041-diff-submodule-option.sh\n> > +++ b/t/t4041-diff-submodule-option.sh\n> > @@ -14,7 +14,11 @@ export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME\n> >\n> >  . ./test-lib.sh\n> >\n> > -test_expect_success SHA1 'submodule commit abbreviation uses submodule object database' '\n> > +test_expect_success 'submodule commit abbreviation uses submodule object database' '\n> > +     test_oid_cache <<-EOF &&\n> > +     submodule_commit1_abbrev sha1:0000000000e\n> > +     submodule_commit1_abbrev sha256:24c81a5\n> > +     EOF\n> >       test_when_finished \"rm -rf collision-super\" &&\n> >       git init -q collision-super &&\n> >       git init -q collision-super/sm1 &&\n> > @@ -27,7 +31,8 @@ test_expect_success SHA1 'submodule commit abbreviation uses submodule object da\n> >       git -C collision-super update-index --add --cacheinfo 160000,\"$commit1\",sm1 &&\n> >       git -C collision-super commit -q -m \"Add submodule\" &&\n> >       git -C collision-super diff --submodule=log >actual &&\n> > -     printf \"Submodule sm1 0000000000e..%s:\\n  > child\\n\" \\\n> > +     printf \"Submodule sm1 %s..%s:\\n  > child\\n\" \\\n> > +             \"$(test_oid submodule_commit1_abbrev)\" \\\n> >               \"$(git -C collision-super/sm1 rev-parse --short \"$commit2\")\" >expected &&\n> >       test_cmp expected actual\n> >  '\n\nHi Usman and Harald,\n\nI wanted to share a progress update on my Git contribution.\n\nI have submitted v5 of my submodule commit abbreviation patch through\nGitGitGadget.\n\nThe latest version incorporates feedback from Junio C. Hamano and\nOkhuomon Ajayi. I combined the implementation and SHA-256 test changes\ninto one commit.\n\nThe targeted test suite, `t4041-diff-submodule-option.sh`, passes all 48 tests.\n\nPR: https://github.com/gitgitgadget/git/pull/2288\n\nI will continue monitoring the review discussion and work on any\nfurther feedback.\n\nRegards,\nSrujith\n\n"},{"id":"557443","messageId":"xmqqwlqs3bm7.fsf@gitster.g","threadId":"66723","inReplyTo":"pull.2288.v5.git.1793763781129.gitgitgadget@gmail.com","subject":"Re: [PATCH v5] submodule: use the submodule repository to abbreviate commits","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2026-11-04T14:38:40Z","receivedAt":"2026-11-04T14:38:40Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"Srujith A Poojary via GitGitGadget\" <gitgitgadget@gmail.com>\nwrites:\n\n> From: Srujith A Poojary <poojarysrujith@gmail.com>\n>\n> The commit IDs shown in a submodule diff header belong to the\n> submodule's object database. However, strbuf_add_unique_abbrev()\n> uses the_repository, so it checks the superproject's object\n> database when abbreviating those IDs.\n>\n> Use the submodule repository when it is available, and fall back\n> to the repository from the diff options when it is not.\n>\n> The expected abbreviation for a submodule commit depends on the\n> repository's hash algorithm. Use test_oid_cache to provide the\n> expected value for each algorithm and remove the SHA1 prerequisite\n> so this test runs with both SHA-1 and SHA-256.\n\n\"remove\"?  What are you talking about???\n\nAbove the three-dash line, decribe the change to those who read\n_ONLY_ this iteration, not any earlier ones, because that is what\n\"git log\" readers will see.  Perhaps write it more like\n\n    As the expected abbreviation depends on the hash algorithm used,\n    the test uses the test_oid mechanism to switch the expectation\n    between SHA-1 and SHA-256 repositories.\n\nor something, if you want to help readers who are not as familiar\nwith our system and its test infrastructure as you are understand\nwhat you did.\n\n> Signed-off-by: Srujith A Poojary <poojarysrujith@gmail.com>\n> ---\n\nHere below the three-dash line is a place for you to describe what\nchanged since the earlier rounds in your own words.  Range-diff is\nadded to aid it, but not as a replacement.\n\nChanges since v4 is to squash two pieces into a single patch, as far\nas I can tell.  Such a change is not visible in range-diff as #2\ngoes away, readers cannot tell where the additional material in #1\ncame from.\n\nOverall it is looking good.  Thanks.\n\n"},{"id":"557494","messageId":"pull.2288.v6.git.1793821554097.gitgitgadget@gmail.com","threadId":"66723","inReplyTo":"pull.2288.git.1793435149942.gitgitgadget@gmail.com","subject":"[PATCH v6] submodule: use the submodule repository to abbreviate commits","fromName":"Srujith A Poojary via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2026-11-04T19:45:54Z","receivedAt":"2026-11-04T19:45:54Z","isPatch":true,"sender":{"key":"name:Srujith A Poojary","avatar":null},"body":"From: Srujith A Poojary <poojarysrujith@gmail.com>\n\nThe commit IDs shown in a submodule diff header belong to the\nsubmodule's object database. However, strbuf_add_unique_abbrev()\nuses the_repository, so it checks the superproject's object\ndatabase when abbreviating those IDs.\n\nUse the submodule repository when it is available, and fall back\nto the repository from the diff options when it is not.\n\nAs the expected abbreviation depends on the hash algorithm used,\nthe test uses the test_oid mechanism to switch the expectation\nbetween SHA-1 and SHA-256 repositories.\n\nSigned-off-by: Srujith A Poojary <poojarysrujith@gmail.com>\n---\n    [Outreachy PATCH] t4041: use submodule repository for commit\n    abbreviations\n    \n    Changes since v4:\n    \n     * Combine the implementation and SHA-256 test updates into a single\n       patch.\n     * Update the commit message to explain how the test uses test_oid to\n       switch expectations between SHA-1 and SHA-256 repositories.\n\nPublished-As: https://github.com/gitgitgadget/git/releases/tag/pr-2288%2Fpoojarysrujith%2Fmicroproject-git-libification-v6\nFetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-2288/poojarysrujith/microproject-git-libification-v6\nPull-Request: https://github.com/gitgitgadget/git/pull/2288\n\nRange-diff vs v5:\n\n 1:  f94aa2476f ! 1:  01c3cc2573 submodule: use the submodule repository to abbreviate commits\n     @@ Commit message\n          Use the submodule repository when it is available, and fall back\n          to the repository from the diff options when it is not.\n      \n     -    The expected abbreviation for a submodule commit depends on the\n     -    repository's hash algorithm. Use test_oid_cache to provide the\n     -    expected value for each algorithm and remove the SHA1 prerequisite\n     -    so this test runs with both SHA-1 and SHA-256.\n     +    As the expected abbreviation depends on the hash algorithm used,\n     +    the test uses the test_oid mechanism to switch the expectation\n     +    between SHA-1 and SHA-256 repositories.\n      \n          Signed-off-by: Srujith A Poojary <poojarysrujith@gmail.com>\n      \n\n\n submodule.c                      |  5 +++--\n t/t4041-diff-submodule-option.sh | 23 +++++++++++++++++++++++\n 2 files changed, 26 insertions(+), 2 deletions(-)\n\ndiff --git a/submodule.c b/submodule.c\nindex 6fcb606f7e..1302c11ddf 100644\n--- a/submodule.c\n+++ b/submodule.c\n@@ -543,6 +543,7 @@ static void show_submodule_header(struct diff_options *o,\n \t\tstruct commit **left, struct commit **right,\n \t\tstruct commit_list **merge_bases)\n {\n+\tstruct repository *repo = sub ? sub : o->repo;\n \tconst char *message = NULL;\n \tstruct strbuf sb = STRBUF_INIT;\n \tint fast_forward = 0, fast_backward = 0;\n@@ -599,9 +600,9 @@ static void show_submodule_header(struct diff_options *o,\n \n output_header:\n \tstrbuf_addf(&sb, \"Submodule %s \", path);\n-\tstrbuf_add_unique_abbrev(&sb, one, DEFAULT_ABBREV);\n+\tstrbuf_repo_add_unique_abbrev(&sb, repo, one, DEFAULT_ABBREV);\n \tstrbuf_addstr(&sb, (fast_backward || fast_forward) ? \"..\" : \"...\");\n-\tstrbuf_add_unique_abbrev(&sb, two, DEFAULT_ABBREV);\n+\tstrbuf_repo_add_unique_abbrev(&sb, repo, two, DEFAULT_ABBREV);\n \tif (message)\n \t\tstrbuf_addf(&sb, \" %s\\n\", message);\n \telse\ndiff --git a/t/t4041-diff-submodule-option.sh b/t/t4041-diff-submodule-option.sh\nindex 4dd4954260..4539d6bba5 100755\n--- a/t/t4041-diff-submodule-option.sh\n+++ b/t/t4041-diff-submodule-option.sh\n@@ -14,6 +14,29 @@ export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME\n \n . ./test-lib.sh\n \n+test_expect_success 'submodule commit abbreviation uses submodule object database' '\n+\ttest_oid_cache <<-EOF &&\n+\tsubmodule_commit1_abbrev sha1:0000000000e\n+\tsubmodule_commit1_abbrev sha256:24c81a5\n+\tEOF\n+\ttest_when_finished \"rm -rf collision-super\" &&\n+\tgit init -q collision-super &&\n+\tgit init -q collision-super/sm1 &&\n+\tprintf \"0\\n1\\n2\\n3\\n4\\n5\\n6\\n7\\n8\\n9\\n\\nb1rwzyc3\\n\" >collision-super/sm1/a0blgqsjc &&\n+\tgit -C collision-super/sm1 add a0blgqsjc &&\n+\ttree=$(git -C collision-super/sm1 write-tree) &&\n+\tcommit1=$(GIT_AUTHOR_DATE=\"1112911993 -0700\" GIT_COMMITTER_DATE=\"1112911993 -0700\" git -C collision-super/sm1 commit-tree \"$tree\" -m a2onsxbvj) &&\n+\tcommit2=$(printf \"child\\n\" | GIT_AUTHOR_DATE=\"1112912053 -0700\" GIT_COMMITTER_DATE=\"1112912053 -0700\" git -C collision-super/sm1 commit-tree \"$tree\" -p \"$commit1\") &&\n+\tgit -C collision-super/sm1 checkout -q \"$commit2\" &&\n+\tgit -C collision-super update-index --add --cacheinfo 160000,\"$commit1\",sm1 &&\n+\tgit -C collision-super commit -q -m \"Add submodule\" &&\n+\tgit -C collision-super diff --submodule=log >actual &&\n+\tprintf \"Submodule sm1 %s..%s:\\n  > child\\n\" \\\n+\t\t\"$(test_oid submodule_commit1_abbrev)\" \\\n+\t\t\"$(git -C collision-super/sm1 rev-parse --short \"$commit2\")\" >expected &&\n+\ttest_cmp expected actual\n+'\n+\n # Test non-UTF-8 encoding in case iconv is available.\n if test_have_prereq ICONV\n then\n\nbase-commit: 50fe5cc63f9cd6e89b87a2c9ccf96a444f4cfdb7\n-- \ngitgitgadget\n\n"}]}