Skip to content

Commit 927b26f

Browse files
bk2204gitster
authored andcommitted
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 <[email protected]> Acked-by: Jens Lehmann <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 2be9450 commit 927b26f

File tree

3 files changed

+27
-2
lines changed

3 files changed

+27
-2
lines changed

git-submodule.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1036,6 +1036,13 @@ cmd_summary() {
10361036
do
10371037
# Always show modules deleted or type-changed (blob<->module)
10381038
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
10391046
# Also show added or modified modules which are checked out
10401047
GIT_DIR="$sm_path/.git" git-rev-parse --git-dir >/dev/null 2>&1 &&
10411048
echo "$sm_path"

t/t7401-submodule-summary.sh

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,24 @@ EOF
104104
test_cmp expected actual
105105
"
106106

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+
107125
commit_file sm1 &&
108126
head3=$(
109127
cd sm1 &&

t/t7508-status.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1316,15 +1316,15 @@ test_expect_success "--ignore-submodules=all suppresses submodule summary" '
13161316
test_i18ncmp expect output
13171317
'
13181318

1319-
test_expect_failure '.gitmodules ignore=all suppresses submodule summary' '
1319+
test_expect_success '.gitmodules ignore=all suppresses submodule summary' '
13201320
git config --add -f .gitmodules submodule.subname.ignore all &&
13211321
git config --add -f .gitmodules submodule.subname.path sm &&
13221322
git status > output &&
13231323
test_cmp expect output &&
13241324
git config -f .gitmodules --remove-section submodule.subname
13251325
'
13261326

1327-
test_expect_failure '.git/config ignore=all suppresses submodule summary' '
1327+
test_expect_success '.git/config ignore=all suppresses submodule summary' '
13281328
git config --add -f .gitmodules submodule.subname.ignore none &&
13291329
git config --add -f .gitmodules submodule.subname.path sm &&
13301330
git config --add submodule.subname.ignore all &&

0 commit comments

Comments
 (0)