submodule: don't print status output with ignore=all

git status prints information for submodules, but it should ignore the status of those which have submodule.<name>.ignore set to all. Fix it so that it does properly ignore those which have that setting either in .git/config or in .gitmodules. Not ignored are submodules that are added, deleted, or moved (which is essentially a combination of the first two) because it is not easily possible to determine the old path once a move has occurred, nor is it easily possible to detect which adds and deletions are moves and which are not. This also preserves the previous behavior of always listing modules which are to be deleted. Tests are included which verify that this change has no effect on git submodule summary without the --for-status option. Signed-off-by: Brian M. Carlson <sandals@crustytoothpaste.net> Acked-by: Jens Lehmann <Jens.Lehmann@web.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Brian M. Carlson committed Sep 1, 2013 at 20:06 UTC 927b26f87a5654349b87d3217ed8e9360d9ff798
3 files changed +27 -2
git-submodule.sh
+7
@@ -1036,6 +1036,13 @@ cmd_summary() {
1036 do
1037 # Always show modules deleted or type-changed (blob<->module)
1038 test $status = D -o $status = T && echo "$sm_path" && continue
1039 + # Respect the ignore setting for --for-status.
1040 + if test -n "$for_status"
1041 + then
1042 + name=$(module_name "$sm_path")
1043 + ignore_config=$(get_submodule_config "$name" ignore none)
1044 + test $status != A -a $ignore_config = all && continue
1045 + fi
1046 # Also show added or modified modules which are checked out
1047 GIT_DIR="$sm_path/.git" git-rev-parse --git-dir >/dev/null 2>&1 &&
1048 echo "$sm_path"
t/t7401-submodule-summary.sh
+18
@@ -104,6 +104,24 @@ EOF
104 test_cmp expected actual
105 "
106
107 +test_expect_success 'no ignore=all setting has any effect' "
108 + git config -f .gitmodules submodule.sm1.path sm1 &&
109 + git config -f .gitmodules submodule.sm1.ignore all &&
110 + git config submodule.sm1.ignore all &&
111 + git config diff.ignoreSubmodules all &&
112 + git submodule summary >actual &&
113 + cat >expected <<-EOF &&
114 +* sm1 $head1...$head2 (1):
115 + > Add foo3
116 +
117 +EOF
118 + test_cmp expected actual &&
119 + git config --unset diff.ignoreSubmodules &&
120 + git config --remove-section submodule.sm1 &&
121 + git config -f .gitmodules --remove-section submodule.sm1
122 +"
123 +
124 +
125 commit_file sm1 &&
126 head3=$(
127 cd sm1 &&
t/t7508-status.sh
+2 -2
@@ -1316,7 +1316,7 @@ test_expect_success "--ignore-submodules=all suppresses submodule summary" '
1316 test_i18ncmp expect output
1317 '
1318
1319 -test_expect_failure '.gitmodules ignore=all suppresses submodule summary' '
1319 +test_expect_success '.gitmodules ignore=all suppresses submodule summary' '
1320 git config --add -f .gitmodules submodule.subname.ignore all &&
1321 git config --add -f .gitmodules submodule.subname.path sm &&
1322 git status > output &&
@@ -1324,7 +1324,7 @@ test_expect_failure '.gitmodules ignore=all suppresses submodule summary' '
1324 git config -f .gitmodules --remove-section submodule.subname
1325 '
1326
1327 -test_expect_failure '.git/config ignore=all suppresses submodule summary' '
1327 +test_expect_success '.git/config ignore=all suppresses submodule summary' '
1328 git config --add -f .gitmodules submodule.subname.ignore none &&
1329 git config --add -f .gitmodules submodule.subname.path sm &&
1330 git config --add submodule.subname.ignore all &&