mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* [Patch] Fixing diff.ignoreSubmodules
@ 2019-05-17 12:11 Allan Jensen
  0 siblings, 0 replies; only message in thread
From: Allan Jensen @ 2019-05-17 12:11 UTC (permalink / raw)

[-- Attachment #1: Type: text/plain, Size: 431 bytes --]

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

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: fix-ignoreSubmodule.diff --]
[-- Type: text/x-patch; name="fix-ignoreSubmodule.diff", Size: 3885 bytes --]

commit 4600b16e3a094a3b35628fc954951117d4d64a06
Author: Allan Sandfeld Jensen <>
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.

diff --git a/Documentation/config/submodule.txt b/Documentation/config/submodule.txt
index 0a1293b051..08daeca753 100644
--- a/Documentation/config/submodule.txt
+++ b/Documentation/config/submodule.txt
@@ -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.
 	Boolean value indicating if the submodule is of interest to git
diff --git a/diff.c b/diff.c
index 4d3cf83a27..9b465d5f6c 100644
--- a/diff.c
+++ b/diff.c
@@ -5074,7 +5074,6 @@ static int diff_opt_ignore_submodules(const struct option *opt,
 	if (!arg)
 		arg = "all";
-	options->flags.override_submodule_config = 1;
 	handle_ignore_submodules_arg(options, arg);
 	return 0;
diff --git a/submodule.c b/submodule.c
index 2cfaba0599..4a3cfe7b36 100644
--- a/submodule.c
+++ b/submodule.c
@@ -420,6 +420,7 @@ const char *submodule_strategy_to_string(const struct submodule_update_strategy
 void 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;
diff --git a/t/ b/t/
index 8f86b5f4b2..05b0c759b9 100755
--- a/t/
+++ b/t/
@@ -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 &&
diff --git a/t/ b/t/
index 9aa8e2b39b..e84358ca02 100755
--- a/t/
+++ b/t/
@@ -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

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2019-05-17 12:12 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-05-17 12:11 [Patch] Fixing diff.ignoreSubmodules Allan Jensen

Code repositories for project(s) associated with this public inbox

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).