From 2be945094ef753a47fa85d54dd472351f77c398c Mon Sep 17 00:00:00 2001 From: "Brian M. Carlson" Date: Sat, 17 Aug 2013 17:25:42 +0000 Subject: submodule: fix confusing variable name cmd_summary reads the output of git diff, but reads in the submodule path into a variable called name. Since this variable does not contain the name of the submodule, but the path, rename it to be clearer what data it actually holds. Signed-off-by: Brian M. Carlson Acked-by: Jens Lehmann Signed-off-by: Junio C Hamano diff --git a/git-submodule.sh b/git-submodule.sh index 2979197..38520db 100755 --- a/git-submodule.sh +++ b/git-submodule.sh @@ -1032,13 +1032,13 @@ cmd_summary() { # Get modified modules cared by user modules=$(git $diff_cmd $cached --ignore-submodules=dirty --raw $head -- "$@" | sane_egrep '^:([0-7]* )?160000' | - while read mod_src mod_dst sha1_src sha1_dst status name + while read mod_src mod_dst sha1_src sha1_dst status sm_path do # Always show modules deleted or type-changed (blob<->module) - test $status = D -o $status = T && echo "$name" && continue + test $status = D -o $status = T && echo "$sm_path" && continue # Also show added or modified modules which are checked out - GIT_DIR="$name/.git" git-rev-parse --git-dir >/dev/null 2>&1 && - echo "$name" + GIT_DIR="$sm_path/.git" git-rev-parse --git-dir >/dev/null 2>&1 && + echo "$sm_path" done ) -- cgit v0.10.2-6-g49f6 From 927b26f87a5654349b87d3217ed8e9360d9ff798 Mon Sep 17 00:00:00 2001 From: "Brian M. Carlson" Date: Sun, 1 Sep 2013 20:06:49 +0000 Subject: 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..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 Acked-by: Jens Lehmann Signed-off-by: Junio C Hamano diff --git a/git-submodule.sh b/git-submodule.sh index 38520db..004b21c 100755 --- a/git-submodule.sh +++ b/git-submodule.sh @@ -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" diff --git a/t/t7401-submodule-summary.sh b/t/t7401-submodule-summary.sh index ac2434c..81ae7c9 100755 --- a/t/t7401-submodule-summary.sh +++ b/t/t7401-submodule-summary.sh @@ -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 && diff --git a/t/t7508-status.sh b/t/t7508-status.sh index ac3d0fe..fb89fb9 100755 --- a/t/t7508-status.sh +++ b/t/t7508-status.sh @@ -1316,7 +1316,7 @@ 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 && @@ -1324,7 +1324,7 @@ test_expect_failure '.gitmodules ignore=all suppresses submodule summary' ' 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 && -- cgit v0.10.2-6-g49f6 From bb58b696c6ad810560d361b640580715a90382cb Mon Sep 17 00:00:00 2001 From: Jens Lehmann Date: Wed, 11 Sep 2013 21:07:15 +0200 Subject: Improve documentation concerning the status.submodulesummary setting 'git status' and 'git commit' can be told to also show the output of "git submodule summary" by setting the "status.submodulesummary" config option. But status and commit also honor the "diff.ignoreSubmodules" and the "submodule..ignore" settings, which then disable the summary partly or completely. This - and the fact that the last two settings do not affect the "git submodule" commands at all - is not well documented. Extend the documentation in those places where "status.submodulesummary", "diff.ignoreSubmodules" and "submodule..ignore" are described to better explain these dependencies. Thanks-to: Matthieu Moy Signed-off-by: Jens Lehmann Signed-off-by: Junio C Hamano diff --git a/Documentation/config.txt b/Documentation/config.txt index ec57a15..424aa51 100644 --- a/Documentation/config.txt +++ b/Documentation/config.txt @@ -2142,7 +2142,14 @@ status.submodulesummary:: If this is set to a non zero number or true (identical to -1 or an unlimited number), the submodule summary will be enabled and a summary of commits for modified submodules will be shown (see - --summary-limit option of linkgit:git-submodule[1]). + --summary-limit option of linkgit:git-submodule[1]). Please note + that the summary output command will be suppressed for all + submodules when `diff.ignoreSubmodules` is set to 'all' or only + for those submodules where `submodule..ignore=all`. To + also view the summary for ignored submodules you can either use + the --ignore-submodules=dirty command line option or the 'git + submodule summary' command, which shows a similar output but does + not honor these settings. submodule..path:: submodule..url:: @@ -2177,7 +2184,8 @@ submodule..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. + "--ignore-submodules" option. The 'git submodule' commands are not + affected by this setting. tar.umask:: This variable can be used to restrict the permission bits of diff --git a/Documentation/diff-config.txt b/Documentation/diff-config.txt index ac77050..223b931 100644 --- a/Documentation/diff-config.txt +++ b/Documentation/diff-config.txt @@ -73,7 +73,11 @@ diff.ignoreSubmodules:: Sets the default value of --ignore-submodules. Note that this affects only 'git diff' Porcelain, and not lower level 'diff' commands such as 'git diff-files'. 'git checkout' also honors - this setting when reporting uncommitted changes. + this setting when reporting uncommitted changes. Setting it to + 'all' disables the submodule summary normally shown by 'git commit' + and 'git status' when 'status.submodulesummary' is set unless it is + overridden by using the --ignore-submodules command line option. + The 'git submodule' commands are not affected by this setting. diff.mnemonicprefix:: If set, 'git diff' uses a prefix pair that is different from the diff --git a/Documentation/git-status.txt b/Documentation/git-status.txt index 9046df9..a4acaa0 100644 --- a/Documentation/git-status.txt +++ b/Documentation/git-status.txt @@ -210,7 +210,13 @@ directory. If `status.submodulesummary` is set to a non zero number or true (identical to -1 or an unlimited number), the submodule summary will be enabled for the long format and a summary of commits for modified submodules will be -shown (see --summary-limit option of linkgit:git-submodule[1]). +shown (see --summary-limit option of linkgit:git-submodule[1]). Please note +that the summary output from the status command will be suppressed for all +submodules when `diff.ignoreSubmodules` is set to 'all' or only for those +submodules where `submodule..ignore=all`. To also view the summary for +ignored submodules you can either use the --ignore-submodules=dirty command +line option or the 'git submodule summary' command, which shows a similar +output but does not honor these settings. SEE ALSO -------- diff --git a/Documentation/gitmodules.txt b/Documentation/gitmodules.txt index 6a1ca4a..f7be93f 100644 --- a/Documentation/gitmodules.txt +++ b/Documentation/gitmodules.txt @@ -75,7 +75,8 @@ submodule..ignore:: the superproject, the setting there will override the one found in .gitmodules. Both settings can be overridden on the command line by using the - "--ignore-submodule" option. + "--ignore-submodule" option. The 'git submodule' commands are not + affected by this setting. EXAMPLES -- cgit v0.10.2-6-g49f6