threads / discuss / 45314

diff.ignoreSubmoudles config setting broken?

Subject: diff.ignoreSubmoudles config setting broken?

## tl;dr

12 messages between Mar 8, 2017 and Mar 9, 2017.

replies: 11people: 5as markdown or json

Sebastian Schuberth· Mar 8, 2017, 12:54 UTC · lore
Hi,
with

$ git --version git version 2.12.0.windows.1

I'm getting

$ git config --global diff.ignoreSubmodules all $ git diff

diff --git a/scanners/scancode-toolkit b/scanners/scancode-toolkit
index 65e5c9c..6b021a8 160000
--- a/scanners/scancode-toolkit
+++ b/scanners/scancode-toolkit
@@ -1 +1 @@
-Subproject commit 65e5c9c9508441c5f62beff4749cf455c6eadc30
+Subproject commit 6b021a8addf6d3c5f2a6ef1af6245e095c21d8ec

but with

$ git diff --ignore-submodules=all

I'm getting the expected empty output.

I can reproduce the same on Linux with "git version 2.11.0". Am I missing something, or is this a bug?

Regards,
Sebastian
Jeff King· Mar 8, 2017, 13:33 UTC · re: Sebastian Schuberth · lore

Re: diff.ignoreSubmoudles config setting broken?

On Wed, Mar 08, 2017 at 01:54:02PM +0100, Sebastian Schuberth wrote:
Show 15 quoted lines
> I'm getting
> 
> $ git config --global diff.ignoreSubmodules all
> $ git diff
> diff --git a/scanners/scancode-toolkit b/scanners/scancode-toolkit
> index 65e5c9c..6b021a8 160000
> --- a/scanners/scancode-toolkit
> +++ b/scanners/scancode-toolkit
> @@ -1 +1 @@
> -Subproject commit 65e5c9c9508441c5f62beff4749cf455c6eadc30
> +Subproject commit 6b021a8addf6d3c5f2a6ef1af6245e095c21d8ec
>
> but with
> 
> $ git diff --ignore-submodules=all

Hrm. Isn't "all" the default? That's what git-diff(1) says (but I've never used the feature myself).

That would imply to me that there's another config option set somewhere (perhaps in the repo-level config). What does:

  git config --show-origin --get-all diff.ignoresubmodules
say?
-Peff
Sebastian Schuberth· Mar 8, 2017, 13:43 UTC · re: Jeff King · lore

Re: diff.ignoreSubmoudles config setting broken?

On Wed, Mar 8, 2017 at 2:33 PM, Jeff King <peff@peff.net> wrote:
Show 25 quoted lines
>> I'm getting
>>
>> $ git config --global diff.ignoreSubmodules all
>> $ git diff
>> diff --git a/scanners/scancode-toolkit b/scanners/scancode-toolkit
>> index 65e5c9c..6b021a8 160000
>> --- a/scanners/scancode-toolkit
>> +++ b/scanners/scancode-toolkit
>> @@ -1 +1 @@
>> -Subproject commit 65e5c9c9508441c5f62beff4749cf455c6eadc30
>> +Subproject commit 6b021a8addf6d3c5f2a6ef1af6245e095c21d8ec
>>
>> but with
>>
>> $ git diff --ignore-submodules=all
>
> Hrm. Isn't "all" the default? That's what git-diff(1) says (but I've
> never used the feature myself).
>
> That would imply to me that there's another config option set somewhere
> (perhaps in the repo-level config). What does:
>
>   git config --show-origin --get-all diff.ignoresubmodules
>
> say?
It says:
file:/home/seschube/.gitconfig  all
-- 
Sebastian Schuberth
Jeff King· Mar 8, 2017, 14:01 UTC · re: Sebastian Schuberth · lore

Re: diff.ignoreSubmoudles config setting broken?

On Wed, Mar 08, 2017 at 02:43:00PM +0100, Sebastian Schuberth wrote:
Show 13 quoted lines
> > Hrm. Isn't "all" the default? That's what git-diff(1) says (but I've
> > never used the feature myself).
> >
> > That would imply to me that there's another config option set somewhere
> > (perhaps in the repo-level config). What does:
> >
> >   git config --show-origin --get-all diff.ignoresubmodules
> >
> > say?
> 
> It says:
> 
> file:/home/seschube/.gitconfig  all

OK, that looks right, so my guess is probably the wrong direction. Peeking at the code, it looks like there may be some per-submodule magic, but I don't know how it all works. So I'll stop looking and wait for somebody more clueful to respond.

-Peff
Sebastian Schuberth· Mar 8, 2017, 15:07 UTC · re: Jeff King · lore

Re: diff.ignoreSubmoudles config setting broken?

On Wed, Mar 8, 2017 at 3:01 PM, Jeff King <peff@peff.net> wrote:
Show 18 quoted lines
>> > Hrm. Isn't "all" the default? That's what git-diff(1) says (but I've
>> > never used the feature myself).
>> >
>> > That would imply to me that there's another config option set somewhere
>> > (perhaps in the repo-level config). What does:
>> >
>> >   git config --show-origin --get-all diff.ignoresubmodules
>> >
>> > say?
>>
>> It says:
>>
>> file:/home/seschube/.gitconfig  all
>
> OK, that looks right, so my guess is probably the wrong direction.
> Peeking at the code, it looks like there may be some per-submodule
> magic, but I don't know how it all works. So I'll stop looking and wait
> for somebody more clueful to respond.
+ Jens
-- 
Sebastian Schuberth
Stefan Beller· Mar 8, 2017, 19:04 UTC · re: Sebastian Schuberth · lore

Re: diff.ignoreSubmoudles config setting broken?

On Wed, Mar 8, 2017 at 7:07 AM, Sebastian Schuberth <sschuberth@gmail.com> wrote:

>
> + Jens
>
+ Jacob Keller, who touched submodule diff display code last.
(I am thinking of fd47ae6a, diff: teach diff to display submodule
difference with an inline diff, 2016-08-31), which is first release as
part of v2.11.0 (that would fit your observance)
Junio C Hamano· Mar 8, 2017, 20:54 UTC · re: Stefan Beller · lore

Re: diff.ignoreSubmoudles config setting broken?

Stefan Beller <sbeller@google.com> writes:
Show 10 quoted lines
> On Wed, Mar 8, 2017 at 7:07 AM, Sebastian Schuberth
> <sschuberth@gmail.com> wrote:
>>
>> + Jens
>>
>
> + Jacob Keller, who touched submodule diff display code last.
> (I am thinking of fd47ae6a, diff: teach diff to display submodule
> difference with an inline diff, 2016-08-31), which is first release as
> part of v2.11.0 (that would fit your observance)
Between these two:
	git -c diff.ignoresubmodules=all diff
	git diff --ignore-submodules=all

one difference is that the latter disables reading extra config from .gitmodules (!) while the former makes the command honor it.

This comes from aee9c7d6 ("Submodules: Add the new "ignore" config option for diff and status", 2010-08-06), which is ancient and predates even v2.0, so if you see problems with v2.12 or v2.11 but not with older ones, that would rule out this theory.

Stefan Beller· Mar 8, 2017, 22:11 UTC · re: Junio C Hamano · lore

Re: diff.ignoreSubmoudles config setting broken?

On Wed, Mar 8, 2017 at 12:54 PM, Junio C Hamano <gitster@pobox.com> wrote:
Show 21 quoted lines
> Stefan Beller <sbeller@google.com> writes:
>
>> On Wed, Mar 8, 2017 at 7:07 AM, Sebastian Schuberth
>> <sschuberth@gmail.com> wrote:
>>>
>>> + Jens
>>>
>>
>> + Jacob Keller, who touched submodule diff display code last.
>> (I am thinking of fd47ae6a, diff: teach diff to display submodule
>> difference with an inline diff, 2016-08-31), which is first release as
>> part of v2.11.0 (that would fit your observance)
>
> Between these two:
>
>         git -c diff.ignoresubmodules=all diff
>         git diff --ignore-submodules=all
>
> one difference is that the latter disables reading extra config from
> .gitmodules (!) while the former makes the command honor it.
>
Yeah the .gitmodules file is a good hint.
Here is my understanding of the precedence:
  command line options > .git/config (in various forms) > .gitmodules
where in the .git config we have precedence levels for different files
  .git/config > ~/.gitconfig
as well as different settings:
  submodule.<name>.ignore > diff.ignoreSubmodules

It is not clear to me how a specific setting in .gitmodules would interact with a submodule-global setting in the config, e.g.

  git config -f .gitmodules submodule. \
      "$(git submodule--helper name scanners/scancode-toolkit)". \
      ignore none
  git config diff.ignoreSubmodules all
  git diff  scanners/scancode-toolkit

From reading the code, I assume "diff.ignoreSubmodules all" takes precedence here nevertheless because the diff.ignoreSubmodules setting is treated on a higher level than the submodule specific setting, despite the submodule specific setting being more specific.

This is a bad example, because it may be intuitive that the value in the .git/config file takes precedence over .gitmodules, but we cannot set diff.ignoreSubmodules in .gitmodules.

Stefan
Junio C Hamano· Mar 8, 2017, 23:08 UTC · re: Stefan Beller · lore

Re: diff.ignoreSubmoudles config setting broken?

Stefan Beller <sbeller@google.com> writes:
Show 13 quoted lines
> Yeah the .gitmodules file is a good hint.
>
> Here is my understanding of the precedence:
>
>   command line options > .git/config (in various forms) > .gitmodules
>
> where in the .git config we have precedence levels for different files
>
>   .git/config > ~/.gitconfig
>
> as well as different settings:
>
>   submodule.<name>.ignore > diff.ignoreSubmodules

I've never understood why people thought it a good idea to let .gitmodules supplied by the upstream override the configuration setting the end user has like this. This is quite bad.

Perhaps this is a good starting point?
 diff.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/diff.c b/diff.c
index a628ac3a95..75b7140c63 100644
--- a/diff.c
+++ b/diff.c
@@ -273,8 +273,11 @@ int git_diff_ui_config(const char *var, const char *value, void *cb)
 	if (!strcmp(var, "diff.orderfile"))
 		return git_config_pathname(&diff_order_file_cfg, var, value);
 
-	if (!strcmp(var, "diff.ignoresubmodules"))
+	if (!strcmp(var, "diff.ignoresubmodules")) {
 		handle_ignore_submodules_arg(&default_diff_options, value);
+		DIFF_OPT_SET(options, OVERRIDE_SUBMODULE_CONFIG);
+		return 0;
+	}
 
 	if (!strcmp(var, "diff.submodule")) {
 		if (parse_submodule_params(&default_diff_options, value))
Stefan Beller· Mar 9, 2017, 01:30 UTC · re: Junio C Hamano · lore

Re: diff.ignoreSubmoudles config setting broken?

On Wed, Mar 8, 2017 at 3:08 PM, Junio C Hamano <gitster@pobox.com> wrote:
> Stefan Beller <sbeller@google.com> writes:
>
>> Yeah the .gitmodules file is a good hint.

And by that I meant that I am not sure if we're going down the right rabbit hole here. So before we take action maybe Sebastian can tell us more about his project (and all configurations and settings involved)

Show 16 quoted lines
>>
>> Here is my understanding of the precedence:
>>
>>   command line options > .git/config (in various forms) > .gitmodules
>>
>> where in the .git config we have precedence levels for different files
>>
>>   .git/config > ~/.gitconfig
>>
>> as well as different settings:
>>
>>   submodule.<name>.ignore > diff.ignoreSubmodules
>
> I've never understood why people thought it a good idea to let
> .gitmodules supplied by the upstream override the configuration
> setting the end user has like this.  This is quite bad.

Apart from from the name <-> path mapping, the .gitmodules file is a collection of suggestions, some more severe than others.

I think the issue here is to define the correct and clear order of precedence, specifically between along these 2 different dimensions (different configuration settings vs different files with configuration), such that the .gitmodules file is only ever consulted when the user has obviously nothing configured that would contradict the .gitmodules file.

Show 18 quoted lines
>
> Perhaps this is a good starting point?
>
>  diff.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/diff.c b/diff.c
> index a628ac3a95..75b7140c63 100644
> --- a/diff.c
> +++ b/diff.c
> @@ -273,8 +273,11 @@ int git_diff_ui_config(const char *var, const char *value, void *cb)
>         if (!strcmp(var, "diff.orderfile"))
>                 return git_config_pathname(&diff_order_file_cfg, var, value);
>
> -       if (!strcmp(var, "diff.ignoresubmodules"))
> +       if (!strcmp(var, "diff.ignoresubmodules")) {
>                 handle_ignore_submodules_arg(&default_diff_options, value);
> +               DIFF_OPT_SET(options, OVERRIDE_SUBMODULE_CONFIG);

s/options/&default_diff_options/ makes it compile. (I did not think whether that is correct though.)

In other occurrences of handle_ignore_submodules_arg, the DIFF_OPT_SET is set before the handle_ignore_submodules_arg, though.

When trying these suggestions, ./t4027-diff-submodule.sh breaks. log on that file yields e.g. 302ad7a9930 (Submodules: Use "ignore" settings from .gitmodules too for diff and status), which tells us that in 2010 people were not as concerned by this, but the user had to use the exact option to override the upstream default-suggestion.

Thanks, Stefan

Sebastian Schuberth· Mar 9, 2017, 16:15 UTC · re: Junio C Hamano · lore

Re: diff.ignoreSubmoudles config setting broken?

On Wed, Mar 8, 2017 at 9:54 PM, Junio C Hamano <gitster@pobox.com> wrote:
Show 12 quoted lines
> Between these two:
>
>         git -c diff.ignoresubmodules=all diff
>         git diff --ignore-submodules=all
>
> one difference is that the latter disables reading extra config from
> .gitmodules (!) while the former makes the command honor it.
>
> This comes from aee9c7d6 ("Submodules: Add the new "ignore" config
> option for diff and status", 2010-08-06), which is ancient and
> predates even v2.0, so if you see problems with v2.12 or v2.11 but
> not with older ones, that would rule out this theory.
Thanks for reminding me of possible settings .gitmodules. Indeed I have
[submodule "scanners/scancode-toolkit"]
        path = scanners/scancode-toolkit
        url = https://github.com/sschuberth/scancode-toolkit.git
        ignore = untracked

in .gitmodules, which explains why globally setting "diff.ignoreSubmodules" to "all" had no effect.

-- 
Sebastian Schuberth
Jacob Keller· Mar 8, 2017, 22:27 UTC · re: Stefan Beller · lore

Re: diff.ignoreSubmoudles config setting broken?

On Wed, Mar 8, 2017 at 11:04 AM, Stefan Beller <sbeller@google.com> wrote:
Show 10 quoted lines
> On Wed, Mar 8, 2017 at 7:07 AM, Sebastian Schuberth
> <sschuberth@gmail.com> wrote:
>>
>> + Jens
>>
>
> + Jacob Keller, who touched submodule diff display code last.
> (I am thinking of fd47ae6a, diff: teach diff to display submodule
> difference with an inline diff, 2016-08-31), which is first release as
> part of v2.11.0 (that would fit your observance)

I don't remember doing anything with ignoreSubmodules, but it's possible I broke it...

-Jake

← back to recent threads