Skip to content

Commit

Permalink
submodule: don't print status output with ignore=all
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Brian M. Carlson authored and Junio C Hamano committed Sep 4, 2013
1 parent 2be9450 commit 927b26f
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 2 deletions.
7 changes: 7 additions & 0 deletions git-submodule.sh
Original file line number Diff line number Diff line change
Expand Up @@ -1036,6 +1036,13 @@ cmd_summary() {
do
# Always show modules deleted or type-changed (blob<->module)
test $status = D -o $status = T && echo "$sm_path" && continue
# Respect the ignore setting for --for-status.
if test -n "$for_status"
then
name=$(module_name "$sm_path")
ignore_config=$(get_submodule_config "$name" ignore none)
test $status != A -a $ignore_config = all && continue
fi
# Also show added or modified modules which are checked out
GIT_DIR="$sm_path/.git" git-rev-parse --git-dir >/dev/null 2>&1 &&
echo "$sm_path"
Expand Down
18 changes: 18 additions & 0 deletions t/t7401-submodule-summary.sh
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,24 @@ EOF
test_cmp expected actual
"

test_expect_success 'no ignore=all setting has any effect' "
git config -f .gitmodules submodule.sm1.path sm1 &&
git config -f .gitmodules submodule.sm1.ignore all &&
git config submodule.sm1.ignore all &&
git config diff.ignoreSubmodules all &&
git submodule summary >actual &&
cat >expected <<-EOF &&
* sm1 $head1...$head2 (1):
> Add foo3
EOF
test_cmp expected actual &&
git config --unset diff.ignoreSubmodules &&
git config --remove-section submodule.sm1 &&
git config -f .gitmodules --remove-section submodule.sm1
"


commit_file sm1 &&
head3=$(
cd sm1 &&
Expand Down
4 changes: 2 additions & 2 deletions t/t7508-status.sh
Original file line number Diff line number Diff line change
Expand Up @@ -1316,15 +1316,15 @@ test_expect_success "--ignore-submodules=all suppresses submodule summary" '
test_i18ncmp expect output
'

test_expect_failure '.gitmodules ignore=all suppresses submodule summary' '
test_expect_success '.gitmodules ignore=all suppresses submodule summary' '
git config --add -f .gitmodules submodule.subname.ignore all &&
git config --add -f .gitmodules submodule.subname.path sm &&
git status > output &&
test_cmp expect output &&
git config -f .gitmodules --remove-section submodule.subname
'

test_expect_failure '.git/config ignore=all suppresses submodule summary' '
test_expect_success '.git/config ignore=all suppresses submodule summary' '
git config --add -f .gitmodules submodule.subname.ignore none &&
git config --add -f .gitmodules submodule.subname.path sm &&
git config --add submodule.subname.ignore all &&
Expand Down

0 comments on commit 927b26f

Please sign in to comment.