{"thread":{"id":"51114","subject":"[Patch] Fixing diff.ignoreSubmodules","startedAt":"2019-05-17T12:12:02Z","lastAt":"2019-05-17T12:12:02Z","messageCount":1,"participants":["Allan Jensen"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"375800","messageId":"4489241.31r3eYUQgx@twilight","threadId":"51114","inReplyTo":null,"subject":"[Patch] Fixing diff.ignoreSubmodules","fromName":"Allan Jensen","fromEmail":"allan.jensen@qt.io","sentAt":"2019-05-17T12:11:54Z","receivedAt":"2019-05-17T12:12:02Z","isPatch":true,"sender":{"key":"allan.jensen@qt.io","avatar":null},"body":"Hi git team\n\nI had trouble getting diff.ignoreSubmodules to work at all in any of my git \nprojects, and googling around I found many other people who also couldn't get \nit to work. I found the source of the issue and attached a patch fixing it, \nthough the old non-working behavior seems to have been almost on purpose.\n(further details are in the change)\n\nFeel free to apply or rewrite as you want.\n\nBest regards\n'Allan\n\ncommit 4600b16e3a094a3b35628fc954951117d4d64a06\nAuthor: Allan Sandfeld Jensen <allan.jensen@qt.io>\nDate:   Fri May 17 14:01:55 2019 +0200\n\n    Fix diff.ignoreSubmodules to match documentation\n    \n    It was not operating as the default value of --ignore-submodules,\n    since unlike the command-line option it was overridden by\n    module.X.ignore. And since many projects set a submobule ignore\n    value by default, diff.ignoreSubmodules was in many cases not\n    working at all.\n\ndiff --git a/Documentation/config/submodule.txt b/Documentation/config/submodule.txt\nindex 0a1293b051..08daeca753 100644\n--- a/Documentation/config/submodule.txt\n+++ b/Documentation/config/submodule.txt\n@@ -43,8 +43,8 @@ submodule.<name>.ignore::\n \tsubmodules that have untracked files in their work tree as changed.\n \tThis setting overrides any setting made in .gitmodules for this submodule,\n \tboth settings can be overridden on the command line by using the\n-\t\"--ignore-submodules\" option. The 'git submodule' commands are not\n-\taffected by this setting.\n+\t\"--ignore-submodules\" option, or setting diff.ignoreSubmodules.\n+\tThe 'git submodule' commands are not affected by this setting.\n \n submodule.<name>.active::\n \tBoolean value indicating if the submodule is of interest to git\ndiff --git a/diff.c b/diff.c\nindex 4d3cf83a27..9b465d5f6c 100644\n--- a/diff.c\n+++ b/diff.c\n@@ -5074,7 +5074,6 @@ static int diff_opt_ignore_submodules(const struct option *opt,\n \tBUG_ON_OPT_NEG(unset);\n \tif (!arg)\n \t\targ = \"all\";\n-\toptions->flags.override_submodule_config = 1;\n \thandle_ignore_submodules_arg(options, arg);\n \treturn 0;\n }\ndiff --git a/submodule.c b/submodule.c\nindex 2cfaba0599..4a3cfe7b36 100644\n--- a/submodule.c\n+++ b/submodule.c\n@@ -420,6 +420,7 @@ const char *submodule_strategy_to_string(const struct submodule_update_strategy\n void handle_ignore_submodules_arg(struct diff_options *diffopt,\n \t\t\t\t  const char *arg)\n {\n+\tdiffopt->flags.override_submodule_config = 1;\n \tdiffopt->flags.ignore_submodules = 0;\n \tdiffopt->flags.ignore_untracked_in_submodules = 0;\n \tdiffopt->flags.ignore_dirty_submodules = 0;\ndiff --git a/t/t2013-checkout-submodule.sh b/t/t2013-checkout-submodule.sh\nindex 8f86b5f4b2..05b0c759b9 100755\n--- a/t/t2013-checkout-submodule.sh\n+++ b/t/t2013-checkout-submodule.sh\n@@ -44,11 +44,11 @@ test_expect_success '\"checkout <submodule>\" honors diff.ignoreSubmodules' '\n \tgit config diff.ignoreSubmodules dirty &&\n \techo x> submodule/untracked &&\n \tgit checkout HEAD >actual 2>&1 &&\n-\ttest_must_be_empty actual\n+\ttest_must_be_empty actual &&\n+\tgit config --unset diff.ignoreSubmodules\n '\n \n test_expect_success '\"checkout <submodule>\" honors submodule.*.ignore from .gitmodules' '\n-\tgit config diff.ignoreSubmodules none &&\n \tgit config -f .gitmodules submodule.submodule.path submodule &&\n \tgit config -f .gitmodules submodule.submodule.ignore untracked &&\n \tgit checkout HEAD >actual 2>&1 &&\ndiff --git a/t/t4027-diff-submodule.sh b/t/t4027-diff-submodule.sh\nindex 9aa8e2b39b..e84358ca02 100755\n--- a/t/t4027-diff-submodule.sh\n+++ b/t/t4027-diff-submodule.sh\n@@ -117,6 +117,7 @@ test_expect_success 'git diff HEAD with dirty submodule (work tree, refs match)\n \tgit config diff.ignoreSubmodules dirty &&\n \tgit diff HEAD >actual &&\n \ttest_must_be_empty actual &&\n+\tgit config --unset diff.ignoreSubmodules &&\n \tgit config --add -f .gitmodules submodule.subname.ignore none &&\n \tgit config --add -f .gitmodules submodule.subname.path sub &&\n \tgit diff HEAD >actual &&\n@@ -143,7 +144,6 @@ test_expect_success 'git diff HEAD with dirty submodule (work tree, refs match)\n \ttest_cmp expect.body actual.body &&\n \tgit config --remove-section submodule.subname &&\n \tgit config --remove-section -f .gitmodules submodule.subname &&\n-\tgit config --unset diff.ignoreSubmodules &&\n \trm .gitmodules\n '\n \n"}]}