{"thread":{"id":"57932","subject":"[PATCH] range-diff: show submodule changes irrespective of diff.submodule","startedAt":"2022-05-30T13:09:25Z","lastAt":"2022-06-07T01:26:28Z","messageCount":9,"participants":["Philippe Blain via GitGitGadget","Ævar Arnfjörð Bjarmason","Philippe Blain","Johannes Schindelin","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"456368","messageId":"pull.1244.git.1653916145441.gitgitgadget@gmail.com","threadId":"57932","inReplyTo":null,"subject":"[PATCH] range-diff: show submodule changes irrespective of diff.submodule","fromName":"Philippe Blain via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2022-05-30T13:09:05Z","receivedAt":"2022-05-30T13:09:25Z","isPatch":true,"sender":{"key":"levraiphilippeblain@gmail.com","avatar":"https://avatars.githubusercontent.com/u/44212482?v=4"},"body":"From: Philippe Blain <levraiphilippeblain@gmail.com>\n\nAfter generating diffs for each range to be compared using a 'git log'\ninvocation, range-diff.c::read_patches looks for the \"diff --git\" header\nin those diffs to recognize the beginning of a new change.\n\nIn a project with submodules, and with 'diff.submodule=log' set in the\nconfig, this header is missing for the diff of a changed submodule, so\nany submodule changes are quietly ignored in the range-diff.\n\nWhen 'diff.submodule=diff' is set in the config, the \"diff --git\" header\nis also missing for the submodule itself, but is shown for submodule\ncontent changes, which can easily confuse 'git range-diff' and lead to\nerrors such as:\n\n    error: git apply: bad git-diff - inconsistent old filename on line 1\n    error: could not parse git header 'diff --git path/to/submodule/and/some/file/within\n    '\n    error: could not parse log for '@{u}..@{1}'\n\nForce the submodule diff format to its default (\"short\") when invoking\n'git log' to generate the patches for each range, such that submodule\nchanges are always shown.\n\nNote that the test must use '--creation-factor=100' to force the second\ncommit in the range not to be considered a complete rewrite.\n\nSigned-off-by: Philippe Blain <levraiphilippeblain@gmail.com>\n---\n    range-diff: show submodule changes irrespective of diff.submodule\n    \n    This fixes a bug that I reported last summer [1].\n    \n    [1]\n    https://lore.kernel.org/git/e469038c-d78c-cd4b-0214-7094746b9281@gmail.com/\n\nPublished-As: https://github.com/gitgitgadget/git/releases/tag/pr-1244%2Fphil-blain%2Frange-diff-submodule-diff-v1\nFetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-1244/phil-blain/range-diff-submodule-diff-v1\nPull-Request: https://github.com/gitgitgadget/git/pull/1244\n\n range-diff.c          |  2 +-\n t/t3206-range-diff.sh | 44 +++++++++++++++++++++++++++++++++++++++++++\n 2 files changed, 45 insertions(+), 1 deletion(-)\n\ndiff --git a/range-diff.c b/range-diff.c\nindex b72eb9fdbee..068bf214544 100644\n--- a/range-diff.c\n+++ b/range-diff.c\n@@ -44,7 +44,7 @@ static int read_patches(const char *range, struct string_list *list,\n \n \tstrvec_pushl(&cp.args, \"log\", \"--no-color\", \"-p\", \"--no-merges\",\n \t\t     \"--reverse\", \"--date-order\", \"--decorate=no\",\n-\t\t     \"--no-prefix\",\n+\t\t     \"--no-prefix\", \"--submodule=short\",\n \t\t     /*\n \t\t      * Choose indicators that are not used anywhere\n \t\t      * else in diffs, but still look reasonable\ndiff --git a/t/t3206-range-diff.sh b/t/t3206-range-diff.sh\nindex e30bc48a290..ac848c42536 100755\n--- a/t/t3206-range-diff.sh\n+++ b/t/t3206-range-diff.sh\n@@ -772,4 +772,48 @@ test_expect_success '--left-only/--right-only' '\n \ttest_cmp expect actual\n '\n \n+test_expect_success 'submodule changes are shown irrespective of diff.submodule' '\n+\tgit init sub-repo &&\n+\ttest_commit -C sub-repo sub-first &&\n+\tsub_oid1=$(git -C sub-repo rev-parse HEAD) &&\n+\ttest_commit -C sub-repo sub-second &&\n+\tsub_oid2=$(git -C sub-repo rev-parse HEAD) &&\n+\ttest_commit -C sub-repo sub-third &&\n+\tsub_oid3=$(git -C sub-repo rev-parse HEAD) &&\n+\n+\tgit checkout -b main-sub topic &&\n+\tgit submodule add ./sub-repo sub &&\n+\tgit -C sub checkout --detach sub-first &&\n+\tgit add sub &&\n+\tgit commit -m \"add sub\" &&\n+\tsup_oid1=$(git rev-parse --short HEAD) &&\n+\tgit checkout -b topic-sub &&\n+\tgit -C sub checkout sub-second &&\n+\tgit add sub &&\n+\tgit commit -m \"change sub\" &&\n+\tsup_oid2=$(git rev-parse --short HEAD) &&\n+\tgit checkout -b modified-sub main-sub &&\n+\tgit -C sub checkout sub-third &&\n+\tgit add sub &&\n+\tgit commit -m \"change sub\" &&\n+\tsup_oid3=$(git rev-parse --short HEAD) &&\n+\n+\ttest_config diff.submodule log &&\n+\tgit range-diff --creation-factor=100 topic topic-sub modified-sub >actual &&\n+\tcat >expect <<-EOF &&\n+\t1:  $sup_oid1 = 1:  $sup_oid1 add sub\n+\t2:  $sup_oid2 ! 2:  $sup_oid3 change sub\n+\t    @@ Commit message\n+\t      ## sub ##\n+\t     @@\n+\t     -Subproject commit $sub_oid1\n+\t    -+Subproject commit $sub_oid2\n+\t    ++Subproject commit $sub_oid3\n+\tEOF\n+\ttest_cmp expect actual &&\n+\ttest_config diff.submodule diff &&\n+\tgit range-diff --creation-factor=100 topic topic-sub modified-sub >actual &&\n+\ttest_cmp expect actual\n+'\n+\n test_done\n\nbase-commit: 7a3eb286977746bc09a5de7682df0e5a7085e17c\n-- \ngitgitgadget\n"},{"id":"456369","messageId":"220530.867d632kso.gmgdl@evledraar.gmail.com","threadId":"57932","inReplyTo":"pull.1244.git.1653916145441.gitgitgadget@gmail.com","subject":"Re: [PATCH] range-diff: show submodule changes irrespective of diff.submodule","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2022-05-30T13:46:22Z","receivedAt":"2022-05-30T14:23:41Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"\nOn Mon, May 30 2022, Philippe Blain via GitGitGadget wrote:\n\n> From: Philippe Blain <levraiphilippeblain@gmail.com>\n>\n> After generating diffs for each range to be compared using a 'git log'\n> invocation, range-diff.c::read_patches looks for the \"diff --git\" header\n> in those diffs to recognize the beginning of a new change.\n>\n> In a project with submodules, and with 'diff.submodule=log' set in the\n> config, this header is missing for the diff of a changed submodule, so\n> any submodule changes are quietly ignored in the range-diff.\n>\n> When 'diff.submodule=diff' is set in the config, the \"diff --git\" header\n> is also missing for the submodule itself, but is shown for submodule\n> content changes, which can easily confuse 'git range-diff' and lead to\n> errors such as:\n>\n>     error: git apply: bad git-diff - inconsistent old filename on line 1\n>     error: could not parse git header 'diff --git path/to/submodule/and/some/file/within\n>     '\n>     error: could not parse log for '@{u}..@{1}'\n>\n> Force the submodule diff format to its default (\"short\") when invoking\n> 'git log' to generate the patches for each range, such that submodule\n> changes are always shown.\n>\n> Note that the test must use '--creation-factor=100' to force the second\n> commit in the range not to be considered a complete rewrite.\n>\n> Signed-off-by: Philippe Blain <levraiphilippeblain@gmail.com>\n> ---\n>     range-diff: show submodule changes irrespective of diff.submodule\n>     \n>     This fixes a bug that I reported last summer [1].\n>     \n>     [1]\n>     https://lore.kernel.org/git/e469038c-d78c-cd4b-0214-7094746b9281@gmail.com/\n>\n> Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-1244%2Fphil-blain%2Frange-diff-submodule-diff-v1\n> Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-1244/phil-blain/range-diff-submodule-diff-v1\n> Pull-Request: https://github.com/gitgitgadget/git/pull/1244\n>\n>  range-diff.c          |  2 +-\n>  t/t3206-range-diff.sh | 44 +++++++++++++++++++++++++++++++++++++++++++\n>  2 files changed, 45 insertions(+), 1 deletion(-)\n\nThanks for picking this up again, and nice to have a test on this\niteration!\n\n> diff --git a/range-diff.c b/range-diff.c\n> index b72eb9fdbee..068bf214544 100644\n> --- a/range-diff.c\n> +++ b/range-diff.c\n> @@ -44,7 +44,7 @@ static int read_patches(const char *range, struct string_list *list,\n>  \n>  \tstrvec_pushl(&cp.args, \"log\", \"--no-color\", \"-p\", \"--no-merges\",\n>  \t\t     \"--reverse\", \"--date-order\", \"--decorate=no\",\n> -\t\t     \"--no-prefix\",\n> +\t\t     \"--no-prefix\", \"--submodule=short\",\n>  \t\t     /*\n>  \t\t      * Choose indicators that are not used anywhere\n>  \t\t      * else in diffs, but still look reasonable\n> diff --git a/t/t3206-range-diff.sh b/t/t3206-range-diff.sh\n> index e30bc48a290..ac848c42536 100755\n> --- a/t/t3206-range-diff.sh\n> +++ b/t/t3206-range-diff.sh\n> @@ -772,4 +772,48 @@ test_expect_success '--left-only/--right-only' '\n>  \ttest_cmp expect actual\n>  '\n>  \n> +test_expect_success 'submodule changes are shown irrespective of diff.submodule' '\n> +\tgit init sub-repo &&\n> +\ttest_commit -C sub-repo sub-first &&\n> +\tsub_oid1=$(git -C sub-repo rev-parse HEAD) &&\n> +\ttest_commit -C sub-repo sub-second &&\n> +\tsub_oid2=$(git -C sub-repo rev-parse HEAD) &&\n> +\ttest_commit -C sub-repo sub-third &&\n> +\tsub_oid3=$(git -C sub-repo rev-parse HEAD) &&\n> +\n> +\tgit checkout -b main-sub topic &&\n> +\tgit submodule add ./sub-repo sub &&\n> +\tgit -C sub checkout --detach sub-first &&\n> +\tgit add sub &&\n> +\tgit commit -m \"add sub\" &&\n> +\tsup_oid1=$(git rev-parse --short HEAD) &&\n> +\tgit checkout -b topic-sub &&\n> +\tgit -C sub checkout sub-second &&\n> +\tgit add sub &&\n> +\tgit commit -m \"change sub\" &&\n> +\tsup_oid2=$(git rev-parse --short HEAD) &&\n> +\tgit checkout -b modified-sub main-sub &&\n> +\tgit -C sub checkout sub-third &&\n> +\tgit add sub &&\n> +\tgit commit -m \"change sub\" &&\n> +\tsup_oid3=$(git rev-parse --short HEAD) &&\n> +\n> +\ttest_config diff.submodule log &&\n> +\tgit range-diff --creation-factor=100 topic topic-sub modified-sub >actual &&\n> +\tcat >expect <<-EOF &&\n> +\t1:  $sup_oid1 = 1:  $sup_oid1 add sub\n> +\t2:  $sup_oid2 ! 2:  $sup_oid3 change sub\n> +\t    @@ Commit message\n> +\t      ## sub ##\n> +\t     @@\n> +\t     -Subproject commit $sub_oid1\n> +\t    -+Subproject commit $sub_oid2\n> +\t    ++Subproject commit $sub_oid3\n> +\tEOF\n> +\ttest_cmp expect actual &&\n> +\ttest_config diff.submodule diff &&\n> +\tgit range-diff --creation-factor=100 topic topic-sub modified-sub >actual &&\n> +\ttest_cmp expect actual\n> +'\n> +\n\nI'd find this much easier to follow if this were a two-part where we do\nmost of this test code in the 1st commit, and assert the current\n(failing) behavior with a test_expect_failure.\n\nThen this commit would narrowly be the bugfix itself.\n\nI also see that the --creation-factor=100 isn't necessary and seems\nsomewhat orthagonal, i.e. we'd like to test this *without* that option\nand see how we behave, i.e. we'll emit the \"full replacement\".\n\nWhy not compare the output without --creation-factor=100, and then just\nhave another --creation-factor=100 test to show what we emit if we \"look\ninto\" those commits and diff their contents?\n"},{"id":"456381","messageId":"5b43fb27-3a57-937f-1106-516ce939d66c@gmail.com","threadId":"57932","inReplyTo":"220530.867d632kso.gmgdl@evledraar.gmail.com","subject":"Re: [PATCH] range-diff: show submodule changes irrespective of diff.submodule","fromName":"Philippe Blain","fromEmail":"levraiphilippeblain@gmail.com","sentAt":"2022-05-31T02:22:13Z","receivedAt":"2022-05-31T02:22:19Z","isPatch":true,"sender":{"key":"levraiphilippeblain@gmail.com","avatar":"https://avatars.githubusercontent.com/u/44212482?v=4"},"body":"Hi Ævar,\n\nLe 2022-05-30 à 09:46, Ævar Arnfjörð Bjarmason a écrit :\n> \n> On Mon, May 30 2022, Philippe Blain via GitGitGadget wrote:\n> \n>> From: Philippe Blain <levraiphilippeblain@gmail.com>\n>>\n>> After generating diffs for each range to be compared using a 'git log'\n>> invocation, range-diff.c::read_patches looks for the \"diff --git\" header\n>> in those diffs to recognize the beginning of a new change.\n>>\n>> In a project with submodules, and with 'diff.submodule=log' set in the\n>> config, this header is missing for the diff of a changed submodule, so\n>> any submodule changes are quietly ignored in the range-diff.\n>>\n>> When 'diff.submodule=diff' is set in the config, the \"diff --git\" header\n>> is also missing for the submodule itself, but is shown for submodule\n>> content changes, which can easily confuse 'git range-diff' and lead to\n>> errors such as:\n>>\n>>     error: git apply: bad git-diff - inconsistent old filename on line 1\n>>     error: could not parse git header 'diff --git path/to/submodule/and/some/file/within\n>>     '\n>>     error: could not parse log for '@{u}..@{1}'\n>>\n>> Force the submodule diff format to its default (\"short\") when invoking\n>> 'git log' to generate the patches for each range, such that submodule\n>> changes are always shown.\n>>\n>> Note that the test must use '--creation-factor=100' to force the second\n>> commit in the range not to be considered a complete rewrite.\n>>\n>> Signed-off-by: Philippe Blain <levraiphilippeblain@gmail.com>\n>> ---\n>>     range-diff: show submodule changes irrespective of diff.submodule\n>>     \n>>     This fixes a bug that I reported last summer [1].\n>>     \n>>     [1]\n>>     https://lore.kernel.org/git/e469038c-d78c-cd4b-0214-7094746b9281@gmail.com/\n>>\n>> Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-1244%2Fphil-blain%2Frange-diff-submodule-diff-v1\n>> Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-1244/phil-blain/range-diff-submodule-diff-v1\n>> Pull-Request: https://github.com/gitgitgadget/git/pull/1244\n>>\n>>  range-diff.c          |  2 +-\n>>  t/t3206-range-diff.sh | 44 +++++++++++++++++++++++++++++++++++++++++++\n>>  2 files changed, 45 insertions(+), 1 deletion(-)\n> \n> Thanks for picking this up again, and nice to have a test on this\n> iteration!\n\nWell, what I sent last summer was really just a bug report with a \"I think\nthis should fix it\" diff, in case anybody wanted to pick it up. \nIt was not sent as a patch, I would not send a \npatch fixing a bug without correponding tests ;)\n\n> \n>> diff --git a/range-diff.c b/range-diff.c\n>> index b72eb9fdbee..068bf214544 100644\n>> --- a/range-diff.c\n>> +++ b/range-diff.c\n>> @@ -44,7 +44,7 @@ static int read_patches(const char *range, struct string_list *list,\n>>  \n>>  \tstrvec_pushl(&cp.args, \"log\", \"--no-color\", \"-p\", \"--no-merges\",\n>>  \t\t     \"--reverse\", \"--date-order\", \"--decorate=no\",\n>> -\t\t     \"--no-prefix\",\n>> +\t\t     \"--no-prefix\", \"--submodule=short\",\n>>  \t\t     /*\n>>  \t\t      * Choose indicators that are not used anywhere\n>>  \t\t      * else in diffs, but still look reasonable\n>> diff --git a/t/t3206-range-diff.sh b/t/t3206-range-diff.sh\n>> index e30bc48a290..ac848c42536 100755\n>> --- a/t/t3206-range-diff.sh\n>> +++ b/t/t3206-range-diff.sh\n>> @@ -772,4 +772,48 @@ test_expect_success '--left-only/--right-only' '\n>>  \ttest_cmp expect actual\n>>  '\n>>  \n>> +test_expect_success 'submodule changes are shown irrespective of diff.submodule' '\n>> +\tgit init sub-repo &&\n>> +\ttest_commit -C sub-repo sub-first &&\n>> +\tsub_oid1=$(git -C sub-repo rev-parse HEAD) &&\n>> +\ttest_commit -C sub-repo sub-second &&\n>> +\tsub_oid2=$(git -C sub-repo rev-parse HEAD) &&\n>> +\ttest_commit -C sub-repo sub-third &&\n>> +\tsub_oid3=$(git -C sub-repo rev-parse HEAD) &&\n>> +\n>> +\tgit checkout -b main-sub topic &&\n>> +\tgit submodule add ./sub-repo sub &&\n>> +\tgit -C sub checkout --detach sub-first &&\n>> +\tgit add sub &&\n>> +\tgit commit -m \"add sub\" &&\n>> +\tsup_oid1=$(git rev-parse --short HEAD) &&\n>> +\tgit checkout -b topic-sub &&\n>> +\tgit -C sub checkout sub-second &&\n>> +\tgit add sub &&\n>> +\tgit commit -m \"change sub\" &&\n>> +\tsup_oid2=$(git rev-parse --short HEAD) &&\n>> +\tgit checkout -b modified-sub main-sub &&\n>> +\tgit -C sub checkout sub-third &&\n>> +\tgit add sub &&\n>> +\tgit commit -m \"change sub\" &&\n>> +\tsup_oid3=$(git rev-parse --short HEAD) &&\n>> +\n>> +\ttest_config diff.submodule log &&\n>> +\tgit range-diff --creation-factor=100 topic topic-sub modified-sub >actual &&\n>> +\tcat >expect <<-EOF &&\n>> +\t1:  $sup_oid1 = 1:  $sup_oid1 add sub\n>> +\t2:  $sup_oid2 ! 2:  $sup_oid3 change sub\n>> +\t    @@ Commit message\n>> +\t      ## sub ##\n>> +\t     @@\n>> +\t     -Subproject commit $sub_oid1\n>> +\t    -+Subproject commit $sub_oid2\n>> +\t    ++Subproject commit $sub_oid3\n>> +\tEOF\n>> +\ttest_cmp expect actual &&\n>> +\ttest_config diff.submodule diff &&\n>> +\tgit range-diff --creation-factor=100 topic topic-sub modified-sub >actual &&\n>> +\ttest_cmp expect actual\n>> +'\n>> +\n> \n> I'd find this much easier to follow if this were a two-part where we do\n> most of this test code in the 1st commit, and assert the current\n> (failing) behavior with a test_expect_failure.\n> \n> Then this commit would narrowly be the bugfix itself.\n\nI agree that I would prefer if it were the norm to do it this way in this \nproject. This way you can check that the test you are adding actually fails\nwithout the fix, not only that it passes with the fix. This is what I usually\ndo locally before sending.\n\nHowever Junio has expressed his view about that approach before [1] and he prefers\nto see regression / bug fixes as a single commit with code and tests. So that's why\nI sent this as a single commit.\n\n> \n> I also see that the --creation-factor=100 isn't necessary and seems\n> somewhat orthagonal, i.e. we'd like to test this *without* that option\n> and see how we behave, i.e. we'll emit the \"full replacement\".\n> \n> Why not compare the output without --creation-factor=100, and then just\n> have another --creation-factor=100 test to show what we emit if we \"look\n> into\" those commits and diff their contents?\n> \n\nOK, I think this makes sense. It's true that even without '--creation-factor=100',\nwith '-c diff.submodule=log' we end up showing the second commit as an exact match\nin both ranges, which is wrong. I'll add that to the test.\n\nThanks for taking a look,\n\nPhilippe.\n\n\n[1] https://lore.kernel.org/git/37DD13D4-FBE4-4DB7-85F5-824E850BA9AE@gmail.com/\n"},{"id":"456527","messageId":"nycvar.QRO.7.76.6.2206021724240.349@tvgsbejvaqbjf.bet","threadId":"57932","inReplyTo":"pull.1244.git.1653916145441.gitgitgadget@gmail.com","subject":"Re: [PATCH] range-diff: show submodule changes irrespective of diff.submodule","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2022-06-02T15:36:40Z","receivedAt":"2022-06-02T15:36:49Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi Philippe,\n\nOn Mon, 30 May 2022, Philippe Blain via GitGitGadget wrote:\n\n> From: Philippe Blain <levraiphilippeblain@gmail.com>\n>\n> After generating diffs for each range to be compared using a 'git log'\n> invocation, range-diff.c::read_patches looks for the \"diff --git\" header\n> in those diffs to recognize the beginning of a new change.\n>\n> In a project with submodules, and with 'diff.submodule=log' set in the\n> config, this header is missing for the diff of a changed submodule, so\n> any submodule changes are quietly ignored in the range-diff.\n\nThis means that we can go two ways here: either we explicitly disable\n`diff.submodule` for the invocation that is spawned from `range-diff`, or\nwe allow it but then handle the diff header as expected.\n\n>\n> When 'diff.submodule=diff' is set in the config, the \"diff --git\" header\n> is also missing for the submodule itself, but is shown for submodule\n> content changes, which can easily confuse 'git range-diff' and lead to\n> errors such as:\n>\n>     error: git apply: bad git-diff - inconsistent old filename on line 1\n>     error: could not parse git header 'diff --git path/to/submodule/and/some/file/within\n>     '\n>     error: could not parse log for '@{u}..@{1}'\n>\n> Force the submodule diff format to its default (\"short\") when invoking\n> 'git log' to generate the patches for each range, such that submodule\n> changes are always shown.\n\nFull disclosure: I do not see much value in range-diffs in the presence of\nsubmodules. Nothing in the design of range-diffs is prepared for\nsubmodules.\n\nBut since `--submodules=short` does not change anything when running\n`range-diff` in repositories without submodules, I don't mind this change.\n\n>\n> Note that the test must use '--creation-factor=100' to force the second\n> commit in the range not to be considered a complete rewrite.\n\nThank you for this considerate note!\n\n>\n> Signed-off-by: Philippe Blain <levraiphilippeblain@gmail.com>\n> ---\n>     range-diff: show submodule changes irrespective of diff.submodule\n>\n>     This fixes a bug that I reported last summer [1].\n>\n>     [1]\n>     https://lore.kernel.org/git/e469038c-d78c-cd4b-0214-7094746b9281@gmail.com/\n>\n> Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-1244%2Fphil-blain%2Frange-diff-submodule-diff-v1\n> Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-1244/phil-blain/range-diff-submodule-diff-v1\n> Pull-Request: https://github.com/gitgitgadget/git/pull/1244\n>\n>  range-diff.c          |  2 +-\n>  t/t3206-range-diff.sh | 44 +++++++++++++++++++++++++++++++++++++++++++\n>  2 files changed, 45 insertions(+), 1 deletion(-)\n>\n> diff --git a/range-diff.c b/range-diff.c\n> index b72eb9fdbee..068bf214544 100644\n> --- a/range-diff.c\n> +++ b/range-diff.c\n> @@ -44,7 +44,7 @@ static int read_patches(const char *range, struct string_list *list,\n>\n>  \tstrvec_pushl(&cp.args, \"log\", \"--no-color\", \"-p\", \"--no-merges\",\n>  \t\t     \"--reverse\", \"--date-order\", \"--decorate=no\",\n> -\t\t     \"--no-prefix\",\n> +\t\t     \"--no-prefix\", \"--submodule=short\",\n\nAs I mentioned above, since this does not change anything in the intended\nscenarios (i.e. without submodules), I am fine with it.\n\n>  \t\t     /*\n>  \t\t      * Choose indicators that are not used anywhere\n>  \t\t      * else in diffs, but still look reasonable\n> diff --git a/t/t3206-range-diff.sh b/t/t3206-range-diff.sh\n> index e30bc48a290..ac848c42536 100755\n> --- a/t/t3206-range-diff.sh\n> +++ b/t/t3206-range-diff.sh\n> @@ -772,4 +772,48 @@ test_expect_success '--left-only/--right-only' '\n>  \ttest_cmp expect actual\n>  '\n>\n> +test_expect_success 'submodule changes are shown irrespective of diff.submodule' '\n> +\tgit init sub-repo &&\n> +\ttest_commit -C sub-repo sub-first &&\n> +\tsub_oid1=$(git -C sub-repo rev-parse HEAD) &&\n> +\ttest_commit -C sub-repo sub-second &&\n> +\tsub_oid2=$(git -C sub-repo rev-parse HEAD) &&\n> +\ttest_commit -C sub-repo sub-third &&\n> +\tsub_oid3=$(git -C sub-repo rev-parse HEAD) &&\n> +\n> +\tgit checkout -b main-sub topic &&\n> +\tgit submodule add ./sub-repo sub &&\n> +\tgit -C sub checkout --detach sub-first &&\n> +\tgit add sub &&\n> +\tgit commit -m \"add sub\" &&\n\nJust a suggestion: use `git commit -m sub-first sub` instead (one `git`\ninvocation instead of two).\n\n> +\tsup_oid1=$(git rev-parse --short HEAD) &&\n> +\tgit checkout -b topic-sub &&\n> +\tgit -C sub checkout sub-second &&\n> +\tgit add sub &&\n> +\tgit commit -m \"change sub\" &&\n> +\tsup_oid2=$(git rev-parse --short HEAD) &&\n> +\tgit checkout -b modified-sub main-sub &&\n\nAnother suggestion: instead of naming the branches, use the `sup_oid*`\nvariables directly.\n\n> +\tgit -C sub checkout sub-third &&\n> +\tgit add sub &&\n> +\tgit commit -m \"change sub\" &&\n> +\tsup_oid3=$(git rev-parse --short HEAD) &&\n> +\n> +\ttest_config diff.submodule log &&\n> +\tgit range-diff --creation-factor=100 topic topic-sub modified-sub >actual &&\n> +\tcat >expect <<-EOF &&\n> +\t1:  $sup_oid1 = 1:  $sup_oid1 add sub\n> +\t2:  $sup_oid2 ! 2:  $sup_oid3 change sub\n> +\t    @@ Commit message\n> +\t      ## sub ##\n> +\t     @@\n> +\t     -Subproject commit $sub_oid1\n> +\t    -+Subproject commit $sub_oid2\n> +\t    ++Subproject commit $sub_oid3\n> +\tEOF\n> +\ttest_cmp expect actual &&\n> +\ttest_config diff.submodule diff &&\n> +\tgit range-diff --creation-factor=100 topic topic-sub modified-sub >actual &&\n> +\ttest_cmp expect actual\n> +'\n\nThis test case is very clear and concise, even without my suggested\nchanges. Therefore, if you want to keep the patch as-is, I am fine with\nthat, too.\n\nAcked-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n\nThank you,\nDscho\n\n> +\n>  test_done\n>\n> base-commit: 7a3eb286977746bc09a5de7682df0e5a7085e17c\n> --\n> gitgitgadget\n>\n"},{"id":"456533","messageId":"xmqqwndznf0z.fsf@gitster.g","threadId":"57932","inReplyTo":"nycvar.QRO.7.76.6.2206021724240.349@tvgsbejvaqbjf.bet","subject":"Re: [PATCH] range-diff: show submodule changes irrespective of diff.submodule","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2022-06-02T17:36:44Z","receivedAt":"2022-06-02T17:36:56Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:\n\n>> Force the submodule diff format to its default (\"short\") when invoking\n>> 'git log' to generate the patches for each range, such that submodule\n>> changes are always shown.\n>\n> Full disclosure: I do not see much value in range-diffs in the presence of\n> submodules. Nothing in the design of range-diffs is prepared for\n> submodules.\n>\n> But since `--submodules=short` does not change anything when running\n> `range-diff` in repositories without submodules, I don't mind this change.\n\nIOW, \"I wrote it for the purpose of doing X, I do not care those who\nhave been using it for doing Y, I am OK with changing behaviour on\nthem\".\n\nPhilippe, do you have a good guess on other users and workflows that\nmay benefit from the current behaviour?  I suspect in the longer term\nthis might have to become configurable, and I am having a hard time\njudging if (1) a temporary regression (to them) is acceptable or (2)\nthe new feature to also show submodule changes is not urgent enough\nthat it may be better to make it configurable from day one, instead\nof using a different hardcoded and only setting like this patch does.\n\n> This test case is very clear and concise, even without my suggested\n> changes. Therefore, if you want to keep the patch as-is, I am fine with\n> that, too.\n>\n> Acked-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n\nThanks for a review.\n\nWill queue.\n"},{"id":"456752","messageId":"538e55d9-f994-a270-3d6a-a8d2dae9a2cc@gmail.com","threadId":"57932","inReplyTo":"nycvar.QRO.7.76.6.2206021724240.349@tvgsbejvaqbjf.bet","subject":"Re: [PATCH] range-diff: show submodule changes irrespective of diff.submodule","fromName":"Philippe Blain","fromEmail":"levraiphilippeblain@gmail.com","sentAt":"2022-06-06T20:18:38Z","receivedAt":"2022-06-06T20:19:04Z","isPatch":true,"sender":{"key":"levraiphilippeblain@gmail.com","avatar":"https://avatars.githubusercontent.com/u/44212482?v=4"},"body":"Hi Dscho,\n\nLe 2022-06-02 à 11:36, Johannes Schindelin a écrit :\n> Hi Philippe,\n> \n> On Mon, 30 May 2022, Philippe Blain via GitGitGadget wrote:\n> \n>> From: Philippe Blain <levraiphilippeblain@gmail.com>\n>>\n>> After generating diffs for each range to be compared using a 'git log'\n>> invocation, range-diff.c::read_patches looks for the \"diff --git\" header\n>> in those diffs to recognize the beginning of a new change.\n>>\n>> In a project with submodules, and with 'diff.submodule=log' set in the\n>> config, this header is missing for the diff of a changed submodule, so\n>> any submodule changes are quietly ignored in the range-diff.\n> \n> This means that we can go two ways here: either we explicitly disable\n> `diff.submodule` for the invocation that is spawned from `range-diff`, or\n> we allow it but then handle the diff header as expected.\n> \n>>\n>> When 'diff.submodule=diff' is set in the config, the \"diff --git\" header\n>> is also missing for the submodule itself, but is shown for submodule\n>> content changes, which can easily confuse 'git range-diff' and lead to\n>> errors such as:\n>>\n>>     error: git apply: bad git-diff - inconsistent old filename on line 1\n>>     error: could not parse git header 'diff --git path/to/submodule/and/some/file/within\n>>     '\n>>     error: could not parse log for '@{u}..@{1}'\n>>\n>> Force the submodule diff format to its default (\"short\") when invoking\n>> 'git log' to generate the patches for each range, such that submodule\n>> changes are always shown.\n> \n> Full disclosure: I do not see much value in range-diffs in the presence of\n> submodules. Nothing in the design of range-diffs is prepared for\n> submodules.\n> \n> But since `--submodules=short` does not change anything when running\n> `range-diff` in repositories without submodules, I don't mind this change.\n> \n>>\n>> Note that the test must use '--creation-factor=100' to force the second\n>> commit in the range not to be considered a complete rewrite.\n> \n> Thank you for this considerate note!\n> \n>>\n>> Signed-off-by: Philippe Blain <levraiphilippeblain@gmail.com>\n>> ---\n>>     range-diff: show submodule changes irrespective of diff.submodule\n>>\n>>     This fixes a bug that I reported last summer [1].\n>>\n>>     [1]\n>>     https://lore.kernel.org/git/e469038c-d78c-cd4b-0214-7094746b9281@gmail.com/\n>>\n>> Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-1244%2Fphil-blain%2Frange-diff-submodule-diff-v1\n>> Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-1244/phil-blain/range-diff-submodule-diff-v1\n>> Pull-Request: https://github.com/gitgitgadget/git/pull/1244\n>>\n>>  range-diff.c          |  2 +-\n>>  t/t3206-range-diff.sh | 44 +++++++++++++++++++++++++++++++++++++++++++\n>>  2 files changed, 45 insertions(+), 1 deletion(-)\n>>\n>> diff --git a/range-diff.c b/range-diff.c\n>> index b72eb9fdbee..068bf214544 100644\n>> --- a/range-diff.c\n>> +++ b/range-diff.c\n>> @@ -44,7 +44,7 @@ static int read_patches(const char *range, struct string_list *list,\n>>\n>>  \tstrvec_pushl(&cp.args, \"log\", \"--no-color\", \"-p\", \"--no-merges\",\n>>  \t\t     \"--reverse\", \"--date-order\", \"--decorate=no\",\n>> -\t\t     \"--no-prefix\",\n>> +\t\t     \"--no-prefix\", \"--submodule=short\",\n> \n> As I mentioned above, since this does not change anything in the intended\n> scenarios (i.e. without submodules), I am fine with it.\n> \n>>  \t\t     /*\n>>  \t\t      * Choose indicators that are not used anywhere\n>>  \t\t      * else in diffs, but still look reasonable\n>> diff --git a/t/t3206-range-diff.sh b/t/t3206-range-diff.sh\n>> index e30bc48a290..ac848c42536 100755\n>> --- a/t/t3206-range-diff.sh\n>> +++ b/t/t3206-range-diff.sh\n>> @@ -772,4 +772,48 @@ test_expect_success '--left-only/--right-only' '\n>>  \ttest_cmp expect actual\n>>  '\n>>\n>> +test_expect_success 'submodule changes are shown irrespective of diff.submodule' '\n>> +\tgit init sub-repo &&\n>> +\ttest_commit -C sub-repo sub-first &&\n>> +\tsub_oid1=$(git -C sub-repo rev-parse HEAD) &&\n>> +\ttest_commit -C sub-repo sub-second &&\n>> +\tsub_oid2=$(git -C sub-repo rev-parse HEAD) &&\n>> +\ttest_commit -C sub-repo sub-third &&\n>> +\tsub_oid3=$(git -C sub-repo rev-parse HEAD) &&\n>> +\n>> +\tgit checkout -b main-sub topic &&\n>> +\tgit submodule add ./sub-repo sub &&\n>> +\tgit -C sub checkout --detach sub-first &&\n>> +\tgit add sub &&\n>> +\tgit commit -m \"add sub\" &&\n> \n> Just a suggestion: use `git commit -m sub-first sub` instead (one `git`\n> invocation instead of two).\n\nOK, good idea. I'll tweak that.\n\n> \n>> +\tsup_oid1=$(git rev-parse --short HEAD) &&\n>> +\tgit checkout -b topic-sub &&\n>> +\tgit -C sub checkout sub-second &&\n>> +\tgit add sub &&\n>> +\tgit commit -m \"change sub\" &&\n>> +\tsup_oid2=$(git rev-parse --short HEAD) &&\n>> +\tgit checkout -b modified-sub main-sub &&\n> \n> Another suggestion: instead of naming the branches, use the `sup_oid*`\n> variables directly.\n> \n\nI think I like the branch names, they make the test closer to a \n\"real-life\" scenario (in my opinion). So I think I'll keep them,\nsince you write later in your reply that you do not mind that much.\n\n>> +\tgit -C sub checkout sub-third &&\n>> +\tgit add sub &&\n>> +\tgit commit -m \"change sub\" &&\n>> +\tsup_oid3=$(git rev-parse --short HEAD) &&\n>> +\n>> +\ttest_config diff.submodule log &&\n>> +\tgit range-diff --creation-factor=100 topic topic-sub modified-sub >actual &&\n>> +\tcat >expect <<-EOF &&\n>> +\t1:  $sup_oid1 = 1:  $sup_oid1 add sub\n>> +\t2:  $sup_oid2 ! 2:  $sup_oid3 change sub\n>> +\t    @@ Commit message\n>> +\t      ## sub ##\n>> +\t     @@\n>> +\t     -Subproject commit $sub_oid1\n>> +\t    -+Subproject commit $sub_oid2\n>> +\t    ++Subproject commit $sub_oid3\n>> +\tEOF\n>> +\ttest_cmp expect actual &&\n>> +\ttest_config diff.submodule diff &&\n>> +\tgit range-diff --creation-factor=100 topic topic-sub modified-sub >actual &&\n>> +\ttest_cmp expect actual\n>> +'\n> \n> This test case is very clear and concise, even without my suggested\n> changes. Therefore, if you want to keep the patch as-is, I am fine with\n> that, too.\n> \n> Acked-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n> \n> Thank you,\n\nThanks,\n\nPhilippe.\t\n"},{"id":"456753","messageId":"ed907ed2-ee9c-789f-0f25-0a1f5b58714f@gmail.com","threadId":"57932","inReplyTo":"xmqqwndznf0z.fsf@gitster.g","subject":"Re: [PATCH] range-diff: show submodule changes irrespective of diff.submodule","fromName":"Philippe Blain","fromEmail":"levraiphilippeblain@gmail.com","sentAt":"2022-06-06T20:33:35Z","receivedAt":"2022-06-06T20:33:42Z","isPatch":true,"sender":{"key":"levraiphilippeblain@gmail.com","avatar":"https://avatars.githubusercontent.com/u/44212482?v=4"},"body":"Hi Junio,\n\nLe 2022-06-02 à 13:36, Junio C Hamano a écrit :\n> Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:\n> \n>>> Force the submodule diff format to its default (\"short\") when invoking\n>>> 'git log' to generate the patches for each range, such that submodule\n>>> changes are always shown.\n>>\n>> Full disclosure: I do not see much value in range-diffs in the presence of\n>> submodules. Nothing in the design of range-diffs is prepared for\n>> submodules.\n>>\n>> But since `--submodules=short` does not change anything when running\n>> `range-diff` in repositories without submodules, I don't mind this change.\n> \n> IOW, \"I wrote it for the purpose of doing X, I do not care those who\n> have been using it for doing Y, I am OK with changing behaviour on\n> them\".\n> \n> Philippe, do you have a good guess on other users and workflows that\n> may benefit from the current behaviour?  I suspect in the longer term\n> this might have to become configurable, and I am having a hard time\n> judging if (1) a temporary regression (to them) is acceptable or (2)\n> the new feature to also show submodule changes is not urgent enough\n> that it may be better to make it configurable from day one, instead\n> of using a different hardcoded and only setting like this patch does.\n> \nJust to be clear: the \"out of the box\" behaviour (i.e. nothing in the config)\nis correct, i.e. submodule changes are detected and shown by 'git range-diff'.\n\nIt's only if someone has 'diff.submodule={log,diff}' in their config that submodule changes are\nquietly ignored (log) or might crash 'git range-diff' (diff). So I do not think\nof any user or workflow that benefit from the current behaviour, no. If you have \ndiff.submodule={log,diff} set in your config, it's most probably because you work\nin projects that involve submodules and you do care about submodule changes. So \nhaving these changes \"hidden\" by range-diff (or having range-diff crash) just because the output format \nof 'git -c diff.submodule={log,diff} log' does not use a 'diff --git' header for submodules is really\nnot expected. So I do not think we need to make that configurable. I think hardcoding\n'--submodule=short' is an easy fix and a good first step in making 'git range-diff'\nmore useful for submodule users. \n\n\nThanks,\n\nPhilippe.\n"},{"id":"456754","messageId":"pull.1244.v2.git.1654549153769.gitgitgadget@gmail.com","threadId":"57932","inReplyTo":"pull.1244.git.1653916145441.gitgitgadget@gmail.com","subject":"[PATCH v2] range-diff: show submodule changes irrespective of diff.submodule","fromName":"Philippe Blain via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2022-06-06T20:59:13Z","receivedAt":"2022-06-06T21:06:07Z","isPatch":true,"sender":{"key":"levraiphilippeblain@gmail.com","avatar":"https://avatars.githubusercontent.com/u/44212482?v=4"},"body":"From: Philippe Blain <levraiphilippeblain@gmail.com>\n\nAfter generating diffs for each range to be compared using a 'git log'\ninvocation, range-diff.c::read_patches looks for the \"diff --git\" header\nin those diffs to recognize the beginning of a new change.\n\nIn a project with submodules, and with 'diff.submodule=log' set in the\nconfig, this header is missing for the diff of a changed submodule, so\nany submodule changes are quietly ignored in the range-diff.\n\nWhen 'diff.submodule=diff' is set in the config, the \"diff --git\" header\nis also missing for the submodule itself, but is shown for submodule\ncontent changes, which can easily confuse 'git range-diff' and lead to\nerrors such as:\n\n    error: git apply: bad git-diff - inconsistent old filename on line 1\n    error: could not parse git header 'diff --git path/to/submodule/and/some/file/within\n    '\n    error: could not parse log for '@{u}..@{1}'\n\nForce the submodule diff format to its default (\"short\") when invoking\n'git log' to generate the patches for each range, such that submodule\nchanges are always detected.\n\nAdd a test, including an invocation with '--creation-factor=100' to\nforce the second commit in the range not to be considered a complete\nrewrite, in order to verify we do indeed get the \"short\" format.\n\nSigned-off-by: Philippe Blain <levraiphilippeblain@gmail.com>\n---\n    range-diff: show submodule changes irrespective of diff.submodule\n    \n    Changes since v1:\n    \n     * added a comparison without '--creation-factor' to the test, as\n       suggested by Ævar\n     * remove separate 'git add sub' invocations in favor of 'git commit -m\n       msg sub', as suggested by Dscho\n\nPublished-As: https://github.com/gitgitgadget/git/releases/tag/pr-1244%2Fphil-blain%2Frange-diff-submodule-diff-v2\nFetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-1244/phil-blain/range-diff-submodule-diff-v2\nPull-Request: https://github.com/gitgitgadget/git/pull/1244\n\nRange-diff vs v1:\n\n 1:  4ae11694ac6 ! 1:  1982b720a04 range-diff: show submodule changes irrespective of diff.submodule\n     @@ Commit message\n      \n          Force the submodule diff format to its default (\"short\") when invoking\n          'git log' to generate the patches for each range, such that submodule\n     -    changes are always shown.\n     +    changes are always detected.\n      \n     -    Note that the test must use '--creation-factor=100' to force the second\n     -    commit in the range not to be considered a complete rewrite.\n     +    Add a test, including an invocation with '--creation-factor=100' to\n     +    force the second commit in the range not to be considered a complete\n     +    rewrite, in order to verify we do indeed get the \"short\" format.\n      \n          Signed-off-by: Philippe Blain <levraiphilippeblain@gmail.com>\n      \n     @@ t/t3206-range-diff.sh: test_expect_success '--left-only/--right-only' '\n      +\tgit checkout -b main-sub topic &&\n      +\tgit submodule add ./sub-repo sub &&\n      +\tgit -C sub checkout --detach sub-first &&\n     -+\tgit add sub &&\n     -+\tgit commit -m \"add sub\" &&\n     ++\tgit commit -m \"add sub\" sub &&\n      +\tsup_oid1=$(git rev-parse --short HEAD) &&\n      +\tgit checkout -b topic-sub &&\n      +\tgit -C sub checkout sub-second &&\n     -+\tgit add sub &&\n     -+\tgit commit -m \"change sub\" &&\n     ++\tgit commit -m \"change sub\" sub &&\n      +\tsup_oid2=$(git rev-parse --short HEAD) &&\n      +\tgit checkout -b modified-sub main-sub &&\n      +\tgit -C sub checkout sub-third &&\n     -+\tgit add sub &&\n     -+\tgit commit -m \"change sub\" &&\n     ++\tgit commit -m \"change sub\" sub &&\n      +\tsup_oid3=$(git rev-parse --short HEAD) &&\n     ++\tsup_oid0=$(test_oid __) &&\n      +\n      +\ttest_config diff.submodule log &&\n     ++\tgit range-diff topic topic-sub modified-sub >actual &&\n     ++\tcat >expect <<-EOF &&\n     ++\t1:  $sup_oid1 = 1:  $sup_oid1 add sub\n     ++\t2:  $sup_oid2 < -:  $sup_oid0 change sub\n     ++\t-:  $sup_oid0 > 2:  $sup_oid3 change sub\n     ++\tEOF\n     ++\ttest_cmp expect actual &&\n     ++\ttest_config diff.submodule diff &&\n     ++\tgit range-diff topic topic-sub modified-sub >actual &&\n      +\tgit range-diff --creation-factor=100 topic topic-sub modified-sub >actual &&\n      +\tcat >expect <<-EOF &&\n      +\t1:  $sup_oid1 = 1:  $sup_oid1 add sub\n\n\n range-diff.c          |  2 +-\n t/t3206-range-diff.sh | 51 +++++++++++++++++++++++++++++++++++++++++++\n 2 files changed, 52 insertions(+), 1 deletion(-)\n\ndiff --git a/range-diff.c b/range-diff.c\nindex b72eb9fdbee..068bf214544 100644\n--- a/range-diff.c\n+++ b/range-diff.c\n@@ -44,7 +44,7 @@ static int read_patches(const char *range, struct string_list *list,\n \n \tstrvec_pushl(&cp.args, \"log\", \"--no-color\", \"-p\", \"--no-merges\",\n \t\t     \"--reverse\", \"--date-order\", \"--decorate=no\",\n-\t\t     \"--no-prefix\",\n+\t\t     \"--no-prefix\", \"--submodule=short\",\n \t\t     /*\n \t\t      * Choose indicators that are not used anywhere\n \t\t      * else in diffs, but still look reasonable\ndiff --git a/t/t3206-range-diff.sh b/t/t3206-range-diff.sh\nindex e30bc48a290..d12e4e4cc6c 100755\n--- a/t/t3206-range-diff.sh\n+++ b/t/t3206-range-diff.sh\n@@ -772,4 +772,55 @@ test_expect_success '--left-only/--right-only' '\n \ttest_cmp expect actual\n '\n \n+test_expect_success 'submodule changes are shown irrespective of diff.submodule' '\n+\tgit init sub-repo &&\n+\ttest_commit -C sub-repo sub-first &&\n+\tsub_oid1=$(git -C sub-repo rev-parse HEAD) &&\n+\ttest_commit -C sub-repo sub-second &&\n+\tsub_oid2=$(git -C sub-repo rev-parse HEAD) &&\n+\ttest_commit -C sub-repo sub-third &&\n+\tsub_oid3=$(git -C sub-repo rev-parse HEAD) &&\n+\n+\tgit checkout -b main-sub topic &&\n+\tgit submodule add ./sub-repo sub &&\n+\tgit -C sub checkout --detach sub-first &&\n+\tgit commit -m \"add sub\" sub &&\n+\tsup_oid1=$(git rev-parse --short HEAD) &&\n+\tgit checkout -b topic-sub &&\n+\tgit -C sub checkout sub-second &&\n+\tgit commit -m \"change sub\" sub &&\n+\tsup_oid2=$(git rev-parse --short HEAD) &&\n+\tgit checkout -b modified-sub main-sub &&\n+\tgit -C sub checkout sub-third &&\n+\tgit commit -m \"change sub\" sub &&\n+\tsup_oid3=$(git rev-parse --short HEAD) &&\n+\tsup_oid0=$(test_oid __) &&\n+\n+\ttest_config diff.submodule log &&\n+\tgit range-diff topic topic-sub modified-sub >actual &&\n+\tcat >expect <<-EOF &&\n+\t1:  $sup_oid1 = 1:  $sup_oid1 add sub\n+\t2:  $sup_oid2 < -:  $sup_oid0 change sub\n+\t-:  $sup_oid0 > 2:  $sup_oid3 change sub\n+\tEOF\n+\ttest_cmp expect actual &&\n+\ttest_config diff.submodule diff &&\n+\tgit range-diff topic topic-sub modified-sub >actual &&\n+\tgit range-diff --creation-factor=100 topic topic-sub modified-sub >actual &&\n+\tcat >expect <<-EOF &&\n+\t1:  $sup_oid1 = 1:  $sup_oid1 add sub\n+\t2:  $sup_oid2 ! 2:  $sup_oid3 change sub\n+\t    @@ Commit message\n+\t      ## sub ##\n+\t     @@\n+\t     -Subproject commit $sub_oid1\n+\t    -+Subproject commit $sub_oid2\n+\t    ++Subproject commit $sub_oid3\n+\tEOF\n+\ttest_cmp expect actual &&\n+\ttest_config diff.submodule diff &&\n+\tgit range-diff --creation-factor=100 topic topic-sub modified-sub >actual &&\n+\ttest_cmp expect actual\n+'\n+\n test_done\n\nbase-commit: 7a3eb286977746bc09a5de7682df0e5a7085e17c\n-- \ngitgitgadget\n"},{"id":"456768","messageId":"xmqq8rq91cxv.fsf@gitster.g","threadId":"57932","inReplyTo":"ed907ed2-ee9c-789f-0f25-0a1f5b58714f@gmail.com","subject":"Re: [PATCH] range-diff: show submodule changes irrespective of diff.submodule","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2022-06-07T01:26:20Z","receivedAt":"2022-06-07T01:26:28Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Philippe Blain <levraiphilippeblain@gmail.com> writes:\n\n> Just to be clear: the \"out of the box\" behaviour (i.e. nothing in the config)\n> is correct, i.e. submodule changes are detected and shown by 'git range-diff'.\n>\n> It's only if someone has 'diff.submodule={log,diff}' in their\n> config that submodule changes are quietly ignored (log) or might\n> crash 'git range-diff' (diff). So I do not think of any user or\n> workflow that benefit from the current behaviour, no. If you have\n> diff.submodule={log,diff} set in your config, it's most probably\n> because you work in projects that involve submodules and you do\n> care about submodule changes. So having these changes \"hidden\" by\n> range-diff (or having range-diff crash) just because the output\n> format of 'git -c diff.submodule={log,diff} log' does not use a\n> 'diff --git' header for submodules is really not expected. So I do\n> not think we need to make that configurable. I think hardcoding\n> '--submodule=short' is an easy fix and a good first step in making\n> 'git range-diff' more useful for submodule users.\n\nOK.  As \"diff.submodule=none\" does not exist, hardcoding \"short\"\nwould not hurt anybody, I agree.\n\nThanks.\n"}]}