Fixing diff.ignoreSubmodules
PATCH 1/1 Fixing diff.ignoreSubmodules
Hi git team
I had trouble getting diff.ignoreSubmodules to work at all in any of my git projects, and googling around I found many other people who also couldn't get it to work. I found the source of the issue and attached a patch fixing it, though the old non-working behavior seems to have been almost on purpose. (further details are in the change)
Feel free to apply or rewrite as you want.
Best regards
'Allan
commit 4600b16e3a094a3b35628fc954951117d4d64a06
Author: Allan Sandfeld Jensen <[email protected]> Date: Fri May 17 14:01:55 2019 +0200
Fix diff.ignoreSubmodules to match documentation
It was not operating as the default value of --ignore-submodules, since unlike the command-line option it was overridden by module.X.ignore. And since many projects set a submobule ignore value by default, diff.ignoreSubmodules was in many cases not working at all.
Documentation/config/submodule.txt +2 -2
@@ -43,8 +43,8 @@ submodule.<name>.ignore:: submodules that have untracked files in their work tree as changed. This setting overrides any setting made in .gitmodules for this submodule, both settings can be overridden on the command line by using the - "--ignore-submodules" option. The 'git submodule' commands are not - affected by this setting. + "--ignore-submodules" option, or setting diff.ignoreSubmodules. + The 'git submodule' commands are not affected by this setting. submodule.<name>.active:: Boolean value indicating if the submodule is of interest to git
diff.c +0 -1
@@ -5074,7 +5074,6 @@ static int diff_opt_ignore_submodules(const struct option *opt,BUG_ON_OPT_NEG (unset);if (!arg) arg ="all" ; - options->flags.override_submodule_config =1 ;handle_ignore_submodules_arg (options, arg);return 0 ; }
submodule.c +1 -0
@@ -420,6 +420,7 @@ const char *submodule_strategy_to_string(const struct submodule_update_strategyvoid handle_ignore_submodules_arg (struct diff_options *diffopt,const char *arg) { + diffopt->flags.override_submodule_config =1 ; diffopt->flags.ignore_submodules =0 ; diffopt->flags.ignore_untracked_in_submodules =0 ; diffopt->flags.ignore_dirty_submodules =0 ;
t/t2013-checkout-submodule.sh +2 -2
@@ -44,11 +44,11 @@ test_expect_success '"checkout <submodule>" honors diff.ignoreSubmodules' ' git config diff.ignoreSubmodules dirty && echo x> submodule/untracked && git checkout HEAD >actual 2>&1 && - test_must_be_empty actual + test_must_be_empty actual && + git config --unset diff.ignoreSubmodules ' test_expect_success '"checkout <submodule>" honors submodule.*.ignore from .gitmodules' ' - git config diff.ignoreSubmodules none && git config -f .gitmodules submodule.submodule.path submodule && git config -f .gitmodules submodule.submodule.ignore untracked && git checkout HEAD >actual 2>&1 &&
t/t4027-diff-submodule.sh +1 -1
@@ -117,6 +117,7 @@ test_expect_success 'git diff HEAD with dirty submodule (work tree, refs match) git config diff.ignoreSubmodules dirty && git diff HEAD >actual && test_must_be_empty actual && + git config --unset diff.ignoreSubmodules && git config --add -f .gitmodules submodule.subname.ignore none && git config --add -f .gitmodules submodule.subname.path sub && git diff HEAD >actual &&
@@ -143,7 +144,6 @@ test_expect_success 'git diff HEAD with dirty submodule (work tree, refs match) test_cmp expect.body actual.body && git config --remove-section submodule.subname && git config --remove-section -f .gitmodules submodule.subname && - git config --unset diff.ignoreSubmodules && rm .gitmodules '