ref-filter: rename the 'strip' option to 'lstrip'
[gitweb.git] / t / t7508-status.sh
index 8d282802356025761a2b32ffbaec65fec207553c..fb00e6d9b07f4cc6f478bb532749403017599400 100755 (executable)
@@ -7,10 +7,6 @@ test_description='git status'
 
 . ./test-lib.sh
 
-test_expect_success 'use status.displayCommentPrefix by default ' '
-       git config --global status.displayCommentPrefix true
-'
-
 test_expect_success 'status -h in broken repository' '
        git config --global advice.statusuoption false &&
        mkdir broken &&
@@ -65,10 +61,17 @@ test_expect_success 'status (1)' '
 '
 
 strip_comments () {
-       sed "s/^\# //; s/^\#$//; s/^#\t/\t/" <"$1" >"$1".tmp &&
+       tab='   '
+       sed "s/^\# //; s/^\#$//; s/^#$tab/$tab/" <"$1" >"$1".tmp &&
        rm "$1" && mv "$1".tmp "$1"
 }
 
+cat >.gitignore <<\EOF
+.gitignore
+expect*
+output*
+EOF
+
 test_expect_success 'status --column' '
        cat >expect <<\EOF &&
 # On branch master
@@ -86,8 +89,9 @@ test_expect_success 'status --column' '
 # Untracked files:
 #   (use "git add <file>..." to include in what will be committed)
 #
-#      dir1/untracked dir2/untracked output
-#      dir2/modified  expect         untracked
+#      dir1/untracked dir2/untracked
+#      dir2/modified  untracked
+#
 EOF
        COLUMNS=50 git -c status.displayCommentPrefix=true status --column="column dense" >output &&
        test_i18ncmp expect output
@@ -118,9 +122,8 @@ cat >expect <<\EOF
 #      dir1/untracked
 #      dir2/modified
 #      dir2/untracked
-#      expect
-#      output
 #      untracked
+#
 EOF
 
 test_expect_success 'status with status.displayCommentPrefix=true' '
@@ -134,6 +137,23 @@ test_expect_success 'status with status.displayCommentPrefix=false' '
        test_i18ncmp expect output
 '
 
+test_expect_success 'status -v' '
+       (cat expect && git diff --cached) >expect-with-v &&
+       git status -v >output &&
+       test_i18ncmp expect-with-v output
+'
+
+test_expect_success 'status -v -v' '
+       (cat expect &&
+        echo "Changes to be committed:" &&
+        git -c diff.mnemonicprefix=true diff --cached &&
+        echo "--------------------------------------------------" &&
+        echo "Changes not staged for commit:" &&
+        git -c diff.mnemonicprefix=true diff) >expect-with-v &&
+       git status -v -v >output &&
+       test_i18ncmp expect-with-v output
+'
+
 test_expect_success 'setup fake editor' '
        cat >.git/editor <<-\EOF &&
        #! /bin/sh
@@ -157,20 +177,19 @@ test_expect_success 'commit ignores status.displayCommentPrefix=false in COMMIT_
 '
 
 cat >expect <<\EOF
-# On branch master
-# Changes to be committed:
-#      new file:   dir2/added
-#
-# Changes not staged for commit:
-#      modified:   dir1/modified
-#
-# Untracked files:
-#      dir1/untracked
-#      dir2/modified
-#      dir2/untracked
-#      expect
-#      output
-#      untracked
+On branch master
+Changes to be committed:
+       new file:   dir2/added
+
+Changes not staged for commit:
+       modified:   dir1/modified
+
+Untracked files:
+       dir1/untracked
+       dir2/modified
+       dir2/untracked
+       untracked
+
 EOF
 
 test_expect_success 'status (advice.statusHints false)' '
@@ -186,8 +205,6 @@ A  dir2/added
 ?? dir1/untracked
 ?? dir2/modified
 ?? dir2/untracked
-?? expect
-?? output
 ?? untracked
 EOF
 
@@ -201,7 +218,7 @@ test_expect_success 'status -s' '
 test_expect_success 'status with gitignore' '
        {
                echo ".gitignore" &&
-               echo "expect" &&
+               echo "expect*" &&
                echo "output" &&
                echo "untracked"
        } >.gitignore &&
@@ -222,39 +239,43 @@ test_expect_success 'status with gitignore' '
        !! dir1/untracked
        !! dir2/untracked
        !! expect
+       !! expect-with-v
        !! output
        !! untracked
        EOF
        git status -s --ignored >output &&
        test_cmp expect output &&
 
-       cat >expect <<-\EOF &&
-       # On branch master
-       # Changes to be committed:
-       #   (use "git reset HEAD <file>..." to unstage)
-       #
-       #       new file:   dir2/added
-       #
-       # Changes not staged for commit:
-       #   (use "git add <file>..." to update what will be committed)
-       #   (use "git checkout -- <file>..." to discard changes in working directory)
-       #
-       #       modified:   dir1/modified
-       #
-       # Untracked files:
-       #   (use "git add <file>..." to include in what will be committed)
-       #
-       #       dir2/modified
-       # Ignored files:
-       #   (use "git add -f <file>..." to include in what will be committed)
-       #
-       #       .gitignore
-       #       dir1/untracked
-       #       dir2/untracked
-       #       expect
-       #       output
-       #       untracked
-       EOF
+       cat >expect <<\EOF &&
+On branch master
+Changes to be committed:
+  (use "git reset HEAD <file>..." to unstage)
+
+       new file:   dir2/added
+
+Changes not staged for commit:
+  (use "git add <file>..." to update what will be committed)
+  (use "git checkout -- <file>..." to discard changes in working directory)
+
+       modified:   dir1/modified
+
+Untracked files:
+  (use "git add <file>..." to include in what will be committed)
+
+       dir2/modified
+
+Ignored files:
+  (use "git add -f <file>..." to include in what will be committed)
+
+       .gitignore
+       dir1/untracked
+       dir2/untracked
+       expect
+       expect-with-v
+       output
+       untracked
+
+EOF
        git status --ignored >output &&
        test_i18ncmp expect output
 '
@@ -262,7 +283,7 @@ test_expect_success 'status with gitignore' '
 test_expect_success 'status with gitignore (nothing untracked)' '
        {
                echo ".gitignore" &&
-               echo "expect" &&
+               echo "expect*" &&
                echo "dir2/modified" &&
                echo "output" &&
                echo "untracked"
@@ -283,41 +304,48 @@ test_expect_success 'status with gitignore (nothing untracked)' '
        !! dir2/modified
        !! dir2/untracked
        !! expect
+       !! expect-with-v
        !! output
        !! untracked
        EOF
        git status -s --ignored >output &&
        test_cmp expect output &&
 
-       cat >expect <<-\EOF &&
-       # On branch master
-       # Changes to be committed:
-       #   (use "git reset HEAD <file>..." to unstage)
-       #
-       #       new file:   dir2/added
-       #
-       # Changes not staged for commit:
-       #   (use "git add <file>..." to update what will be committed)
-       #   (use "git checkout -- <file>..." to discard changes in working directory)
-       #
-       #       modified:   dir1/modified
-       #
-       # Ignored files:
-       #   (use "git add -f <file>..." to include in what will be committed)
-       #
-       #       .gitignore
-       #       dir1/untracked
-       #       dir2/modified
-       #       dir2/untracked
-       #       expect
-       #       output
-       #       untracked
-       EOF
+       cat >expect <<\EOF &&
+On branch master
+Changes to be committed:
+  (use "git reset HEAD <file>..." to unstage)
+
+       new file:   dir2/added
+
+Changes not staged for commit:
+  (use "git add <file>..." to update what will be committed)
+  (use "git checkout -- <file>..." to discard changes in working directory)
+
+       modified:   dir1/modified
+
+Ignored files:
+  (use "git add -f <file>..." to include in what will be committed)
+
+       .gitignore
+       dir1/untracked
+       dir2/modified
+       dir2/untracked
+       expect
+       expect-with-v
+       output
+       untracked
+
+EOF
        git status --ignored >output &&
        test_i18ncmp expect output
 '
 
-rm -f .gitignore
+cat >.gitignore <<\EOF
+.gitignore
+expect*
+output*
+EOF
 
 cat >expect <<\EOF
 ## master
@@ -326,8 +354,6 @@ A  dir2/added
 ?? dir1/untracked
 ?? dir2/modified
 ?? dir2/untracked
-?? expect
-?? output
 ?? untracked
 EOF
 
@@ -353,22 +379,22 @@ test_expect_success 'setup dir3' '
        : >dir3/untracked2
 '
 
-cat >expect <<EOF
-# On branch master
-# Changes to be committed:
-#   (use "git reset HEAD <file>..." to unstage)
-#
-#      new file:   dir2/added
-#
-# Changes not staged for commit:
-#   (use "git add <file>..." to update what will be committed)
-#   (use "git checkout -- <file>..." to discard changes in working directory)
-#
-#      modified:   dir1/modified
-#
-# Untracked files not listed (use -u option to show untracked files)
-EOF
 test_expect_success 'status -uno' '
+       cat >expect <<EOF &&
+On branch master
+Changes to be committed:
+  (use "git reset HEAD <file>..." to unstage)
+
+       new file:   dir2/added
+
+Changes not staged for commit:
+  (use "git add <file>..." to update what will be committed)
+  (use "git checkout -- <file>..." to discard changes in working directory)
+
+       modified:   dir1/modified
+
+Untracked files not listed (use -u option to show untracked files)
+EOF
        git status -uno >output &&
        test_i18ncmp expect output
 '
@@ -379,17 +405,17 @@ test_expect_success 'status (status.showUntrackedFiles no)' '
        test_i18ncmp expect output
 '
 
-cat >expect <<EOF
-# On branch master
-# Changes to be committed:
-#      new file:   dir2/added
-#
-# Changes not staged for commit:
-#      modified:   dir1/modified
-#
-# Untracked files not listed
-EOF
 test_expect_success 'status -uno (advice.statusHints false)' '
+       cat >expect <<EOF &&
+On branch master
+Changes to be committed:
+       new file:   dir2/added
+
+Changes not staged for commit:
+       modified:   dir1/modified
+
+Untracked files not listed
+EOF
        test_config advice.statusHints false &&
        git status -uno >output &&
        test_i18ncmp expect output
@@ -405,42 +431,41 @@ test_expect_success 'status -s -uno' '
 '
 
 test_expect_success 'status -s (status.showUntrackedFiles no)' '
-       git config status.showuntrackedfiles no
+       git config status.showuntrackedfiles no &&
        git status -s >output &&
        test_cmp expect output
 '
 
-cat >expect <<EOF
-# On branch master
-# Changes to be committed:
-#   (use "git reset HEAD <file>..." to unstage)
-#
-#      new file:   dir2/added
-#
-# Changes not staged for commit:
-#   (use "git add <file>..." to update what will be committed)
-#   (use "git checkout -- <file>..." to discard changes in working directory)
-#
-#      modified:   dir1/modified
-#
-# Untracked files:
-#   (use "git add <file>..." to include in what will be committed)
-#
-#      dir1/untracked
-#      dir2/modified
-#      dir2/untracked
-#      dir3/
-#      expect
-#      output
-#      untracked
-EOF
 test_expect_success 'status -unormal' '
+       cat >expect <<EOF &&
+On branch master
+Changes to be committed:
+  (use "git reset HEAD <file>..." to unstage)
+
+       new file:   dir2/added
+
+Changes not staged for commit:
+  (use "git add <file>..." to update what will be committed)
+  (use "git checkout -- <file>..." to discard changes in working directory)
+
+       modified:   dir1/modified
+
+Untracked files:
+  (use "git add <file>..." to include in what will be committed)
+
+       dir1/untracked
+       dir2/modified
+       dir2/untracked
+       dir3/
+       untracked
+
+EOF
        git status -unormal >output &&
        test_i18ncmp expect output
 '
 
 test_expect_success 'status (status.showUntrackedFiles normal)' '
-       test_config status.showuntrackedfiles normal
+       test_config status.showuntrackedfiles normal &&
        git status >output &&
        test_i18ncmp expect output
 '
@@ -452,8 +477,6 @@ A  dir2/added
 ?? dir2/modified
 ?? dir2/untracked
 ?? dir3/
-?? expect
-?? output
 ?? untracked
 EOF
 test_expect_success 'status -s -unormal' '
@@ -462,43 +485,42 @@ test_expect_success 'status -s -unormal' '
 '
 
 test_expect_success 'status -s (status.showUntrackedFiles normal)' '
-       git config status.showuntrackedfiles normal
+       git config status.showuntrackedfiles normal &&
        git status -s >output &&
        test_cmp expect output
 '
 
-cat >expect <<EOF
-# On branch master
-# Changes to be committed:
-#   (use "git reset HEAD <file>..." to unstage)
-#
-#      new file:   dir2/added
-#
-# Changes not staged for commit:
-#   (use "git add <file>..." to update what will be committed)
-#   (use "git checkout -- <file>..." to discard changes in working directory)
-#
-#      modified:   dir1/modified
-#
-# Untracked files:
-#   (use "git add <file>..." to include in what will be committed)
-#
-#      dir1/untracked
-#      dir2/modified
-#      dir2/untracked
-#      dir3/untracked1
-#      dir3/untracked2
-#      expect
-#      output
-#      untracked
-EOF
 test_expect_success 'status -uall' '
+       cat >expect <<EOF &&
+On branch master
+Changes to be committed:
+  (use "git reset HEAD <file>..." to unstage)
+
+       new file:   dir2/added
+
+Changes not staged for commit:
+  (use "git add <file>..." to update what will be committed)
+  (use "git checkout -- <file>..." to discard changes in working directory)
+
+       modified:   dir1/modified
+
+Untracked files:
+  (use "git add <file>..." to include in what will be committed)
+
+       dir1/untracked
+       dir2/modified
+       dir2/untracked
+       dir3/untracked1
+       dir3/untracked2
+       untracked
+
+EOF
        git status -uall >output &&
        test_i18ncmp expect output
 '
 
 test_expect_success 'status (status.showUntrackedFiles all)' '
-       test_config status.showuntrackedfiles all
+       test_config status.showuntrackedfiles all &&
        git status >output &&
        test_i18ncmp expect output
 '
@@ -513,12 +535,10 @@ A  dir2/added
 ?? dir1/untracked
 ?? dir2/modified
 ?? dir2/untracked
-?? expect
-?? output
 ?? untracked
 EOF
 test_expect_success 'status -s -uall' '
-       git config --unset status.showuntrackedfiles
+       test_unconfig status.showuntrackedfiles &&
        git status -s -uall >output &&
        test_cmp expect output
 '
@@ -529,31 +549,29 @@ test_expect_success 'status -s (status.showUntrackedFiles all)' '
        test_cmp expect output
 '
 
-cat >expect <<\EOF
-# On branch master
-# Changes to be committed:
-#   (use "git reset HEAD <file>..." to unstage)
-#
-#      new file:   ../dir2/added
-#
-# Changes not staged for commit:
-#   (use "git add <file>..." to update what will be committed)
-#   (use "git checkout -- <file>..." to discard changes in working directory)
-#
-#      modified:   modified
-#
-# Untracked files:
-#   (use "git add <file>..." to include in what will be committed)
-#
-#      untracked
-#      ../dir2/modified
-#      ../dir2/untracked
-#      ../expect
-#      ../output
-#      ../untracked
-EOF
-
 test_expect_success 'status with relative paths' '
+       cat >expect <<\EOF &&
+On branch master
+Changes to be committed:
+  (use "git reset HEAD <file>..." to unstage)
+
+       new file:   ../dir2/added
+
+Changes not staged for commit:
+  (use "git add <file>..." to update what will be committed)
+  (use "git checkout -- <file>..." to discard changes in working directory)
+
+       modified:   modified
+
+Untracked files:
+  (use "git add <file>..." to include in what will be committed)
+
+       untracked
+       ../dir2/modified
+       ../dir2/untracked
+       ../untracked
+
+EOF
        (cd dir1 && git status) >output &&
        test_i18ncmp expect output
 '
@@ -564,8 +582,6 @@ A  ../dir2/added
 ?? untracked
 ?? ../dir2/modified
 ?? ../dir2/untracked
-?? ../expect
-?? ../output
 ?? ../untracked
 EOF
 test_expect_success 'status -s with relative paths' '
@@ -581,8 +597,6 @@ A  dir2/added
 ?? dir1/untracked
 ?? dir2/modified
 ?? dir2/untracked
-?? expect
-?? output
 ?? untracked
 EOF
 
@@ -600,31 +614,29 @@ test_expect_success 'setup unique colors' '
 
 '
 
-cat >expect <<\EOF
-# On branch <GREEN>master<RESET>
-# Changes to be committed:
-#   (use "git reset HEAD <file>..." to unstage)
-#
-#      <GREEN>new file:   dir2/added<RESET>
-#
-# Changes not staged for commit:
-#   (use "git add <file>..." to update what will be committed)
-#   (use "git checkout -- <file>..." to discard changes in working directory)
-#
-#      <RED>modified:   dir1/modified<RESET>
-#
-# Untracked files:
-#   (use "git add <file>..." to include in what will be committed)
-#
-#      <BLUE>dir1/untracked<RESET>
-#      <BLUE>dir2/modified<RESET>
-#      <BLUE>dir2/untracked<RESET>
-#      <BLUE>expect<RESET>
-#      <BLUE>output<RESET>
-#      <BLUE>untracked<RESET>
-EOF
-
 test_expect_success 'status with color.ui' '
+       cat >expect <<\EOF &&
+On branch <GREEN>master<RESET>
+Changes to be committed:
+  (use "git reset HEAD <file>..." to unstage)
+
+       <GREEN>new file:   dir2/added<RESET>
+
+Changes not staged for commit:
+  (use "git add <file>..." to update what will be committed)
+  (use "git checkout -- <file>..." to discard changes in working directory)
+
+       <RED>modified:   dir1/modified<RESET>
+
+Untracked files:
+  (use "git add <file>..." to include in what will be committed)
+
+       <BLUE>dir1/untracked<RESET>
+       <BLUE>dir2/modified<RESET>
+       <BLUE>dir2/untracked<RESET>
+       <BLUE>untracked<RESET>
+
+EOF
        test_config color.ui always &&
        git status | test_decode_color >output &&
        test_i18ncmp expect output
@@ -642,8 +654,6 @@ cat >expect <<\EOF
 <BLUE>??<RESET> dir1/untracked
 <BLUE>??<RESET> dir2/modified
 <BLUE>??<RESET> dir2/untracked
-<BLUE>??<RESET> expect
-<BLUE>??<RESET> output
 <BLUE>??<RESET> untracked
 EOF
 
@@ -671,8 +681,6 @@ cat >expect <<\EOF
 <BLUE>??<RESET> dir1/untracked
 <BLUE>??<RESET> dir2/modified
 <BLUE>??<RESET> dir2/untracked
-<BLUE>??<RESET> expect
-<BLUE>??<RESET> output
 <BLUE>??<RESET> untracked
 EOF
 
@@ -689,8 +697,6 @@ A  dir2/added
 ?? dir1/untracked
 ?? dir2/modified
 ?? dir2/untracked
-?? expect
-?? output
 ?? untracked
 EOF
 
@@ -728,33 +734,31 @@ test_expect_success 'status --porcelain respects -b' '
 
 '
 
-cat >expect <<\EOF
-# On branch master
-# Changes to be committed:
-#   (use "git reset HEAD <file>..." to unstage)
-#
-#      new file:   dir2/added
-#
-# Changes not staged for commit:
-#   (use "git add <file>..." to update what will be committed)
-#   (use "git checkout -- <file>..." to discard changes in working directory)
-#
-#      modified:   dir1/modified
-#
-# Untracked files:
-#   (use "git add <file>..." to include in what will be committed)
-#
-#      dir1/untracked
-#      dir2/modified
-#      dir2/untracked
-#      expect
-#      output
-#      untracked
-EOF
 
 
 test_expect_success 'status without relative paths' '
+       cat >expect <<\EOF &&
+On branch master
+Changes to be committed:
+  (use "git reset HEAD <file>..." to unstage)
+
+       new file:   dir2/added
+
+Changes not staged for commit:
+  (use "git add <file>..." to update what will be committed)
+  (use "git checkout -- <file>..." to discard changes in working directory)
+
+       modified:   dir1/modified
+
+Untracked files:
+  (use "git add <file>..." to include in what will be committed)
 
+       dir1/untracked
+       dir2/modified
+       dir2/untracked
+       untracked
+
+EOF
        test_config status.relativePaths false &&
        (cd dir1 && git status) >output &&
        test_i18ncmp expect output
@@ -767,8 +771,6 @@ A  dir2/added
 ?? dir1/untracked
 ?? dir2/modified
 ?? dir2/untracked
-?? expect
-?? output
 ?? untracked
 EOF
 
@@ -780,29 +782,28 @@ test_expect_success 'status -s without relative paths' '
 
 '
 
-cat <<EOF >expect
-# On branch master
-# Changes to be committed:
-#   (use "git reset HEAD <file>..." to unstage)
-#
-#      modified:   dir1/modified
-#
-# Untracked files:
-#   (use "git add <file>..." to include in what will be committed)
-#
-#      dir1/untracked
-#      dir2/
-#      expect
-#      output
-#      untracked
-EOF
 test_expect_success 'dry-run of partial commit excluding new file in index' '
+       cat >expect <<EOF &&
+On branch master
+Changes to be committed:
+  (use "git reset HEAD <file>..." to unstage)
+
+       modified:   dir1/modified
+
+Untracked files:
+  (use "git add <file>..." to include in what will be committed)
+
+       dir1/untracked
+       dir2/
+       untracked
+
+EOF
        git commit --dry-run dir1/modified >output &&
        test_i18ncmp expect output
 '
 
 cat >expect <<EOF
-:100644 100644 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 0000000000000000000000000000000000000000 M     dir1/modified
+:100644 100644 $EMPTY_BLOB 0000000000000000000000000000000000000000 M  dir1/modified
 EOF
 test_expect_success 'status refreshes the index' '
        touch dir2/added &&
@@ -821,31 +822,30 @@ test_expect_success 'setup status submodule summary' '
        git add sm
 '
 
-cat >expect <<EOF
-# On branch master
-# Changes to be committed:
-#   (use "git reset HEAD <file>..." to unstage)
-#
-#      new file:   dir2/added
-#      new file:   sm
-#
-# Changes not staged for commit:
-#   (use "git add <file>..." to update what will be committed)
-#   (use "git checkout -- <file>..." to discard changes in working directory)
-#
-#      modified:   dir1/modified
-#
-# Untracked files:
-#   (use "git add <file>..." to include in what will be committed)
-#
-#      dir1/untracked
-#      dir2/modified
-#      dir2/untracked
-#      expect
-#      output
-#      untracked
-EOF
 test_expect_success 'status submodule summary is disabled by default' '
+       cat >expect <<EOF &&
+On branch master
+Changes to be committed:
+  (use "git reset HEAD <file>..." to unstage)
+
+       new file:   dir2/added
+       new file:   sm
+
+Changes not staged for commit:
+  (use "git add <file>..." to update what will be committed)
+  (use "git checkout -- <file>..." to discard changes in working directory)
+
+       modified:   dir1/modified
+
+Untracked files:
+  (use "git add <file>..." to include in what will be committed)
+
+       dir1/untracked
+       dir2/modified
+       dir2/untracked
+       untracked
+
+EOF
        git status >output &&
        test_i18ncmp expect output
 '
@@ -863,8 +863,6 @@ A  sm
 ?? dir1/untracked
 ?? dir2/modified
 ?? dir2/untracked
-?? expect
-?? output
 ?? untracked
 EOF
 test_expect_success 'status -s submodule summary is disabled by default' '
@@ -880,36 +878,35 @@ test_expect_success 'status -s --untracked-files=all does not show submodule' '
 
 head=$(cd sm && git rev-parse --short=7 --verify HEAD)
 
-cat >expect <<EOF
-# On branch master
-# Changes to be committed:
-#   (use "git reset HEAD <file>..." to unstage)
-#
-#      new file:   dir2/added
-#      new file:   sm
-#
-# Changes not staged for commit:
-#   (use "git add <file>..." to update what will be committed)
-#   (use "git checkout -- <file>..." to discard changes in working directory)
-#
-#      modified:   dir1/modified
-#
-# Submodule changes to be committed:
-#
-# * sm 0000000...$head (1):
-#   > Add foo
-#
-# Untracked files:
-#   (use "git add <file>..." to include in what will be committed)
-#
-#      dir1/untracked
-#      dir2/modified
-#      dir2/untracked
-#      expect
-#      output
-#      untracked
-EOF
 test_expect_success 'status submodule summary' '
+       cat >expect <<EOF &&
+On branch master
+Changes to be committed:
+  (use "git reset HEAD <file>..." to unstage)
+
+       new file:   dir2/added
+       new file:   sm
+
+Changes not staged for commit:
+  (use "git add <file>..." to update what will be committed)
+  (use "git checkout -- <file>..." to discard changes in working directory)
+
+       modified:   dir1/modified
+
+Submodule changes to be committed:
+
+* sm 0000000...$head (1):
+  > Add foo
+
+Untracked files:
+  (use "git add <file>..." to include in what will be committed)
+
+       dir1/untracked
+       dir2/modified
+       dir2/untracked
+       untracked
+
+EOF
        git config status.submodulesummary 10 &&
        git status >output &&
        test_i18ncmp expect output
@@ -932,8 +929,6 @@ A  sm
 ?? dir1/untracked
 ?? dir2/modified
 ?? dir2/untracked
-?? expect
-?? output
 ?? untracked
 EOF
 test_expect_success 'status -s submodule summary' '
@@ -941,26 +936,25 @@ test_expect_success 'status -s submodule summary' '
        test_cmp expect output
 '
 
-cat >expect <<EOF
-# On branch master
-# Changes not staged for commit:
-#   (use "git add <file>..." to update what will be committed)
-#   (use "git checkout -- <file>..." to discard changes in working directory)
-#
-#      modified:   dir1/modified
-#
-# Untracked files:
-#   (use "git add <file>..." to include in what will be committed)
-#
-#      dir1/untracked
-#      dir2/modified
-#      dir2/untracked
-#      expect
-#      output
-#      untracked
+test_expect_success 'status submodule summary (clean submodule): commit' '
+       cat >expect <<EOF &&
+On branch master
+Changes not staged for commit:
+  (use "git add <file>..." to update what will be committed)
+  (use "git checkout -- <file>..." to discard changes in working directory)
+
+       modified:   dir1/modified
+
+Untracked files:
+  (use "git add <file>..." to include in what will be committed)
+
+       dir1/untracked
+       dir2/modified
+       dir2/untracked
+       untracked
+
 no changes added to commit (use "git add" and/or "git commit -a")
 EOF
-test_expect_success 'status submodule summary (clean submodule): commit' '
        git commit -m "commit submodule" &&
        git config status.submodulesummary 10 &&
        test_must_fail git commit --dry-run >output &&
@@ -974,8 +968,6 @@ cat >expect <<EOF
 ?? dir1/untracked
 ?? dir2/modified
 ?? dir2/untracked
-?? expect
-?? output
 ?? untracked
 EOF
 test_expect_success 'status -s submodule summary (clean submodule)' '
@@ -985,41 +977,40 @@ test_expect_success 'status -s submodule summary (clean submodule)' '
 
 test_expect_success 'status -z implies porcelain' '
        git status --porcelain |
-       "$PERL_PATH" -pe "s/\012/\000/g" >expect &&
+       perl -pe "s/\012/\000/g" >expect &&
        git status -z >output &&
        test_cmp expect output
 '
 
-cat >expect <<EOF
-# On branch master
-# Changes to be committed:
-#   (use "git reset HEAD^1 <file>..." to unstage)
-#
-#      new file:   dir2/added
-#      new file:   sm
-#
-# Changes not staged for commit:
-#   (use "git add <file>..." to update what will be committed)
-#   (use "git checkout -- <file>..." to discard changes in working directory)
-#
-#      modified:   dir1/modified
-#
-# Submodule changes to be committed:
-#
-# * sm 0000000...$head (1):
-#   > Add foo
-#
-# Untracked files:
-#   (use "git add <file>..." to include in what will be committed)
-#
-#      dir1/untracked
-#      dir2/modified
-#      dir2/untracked
-#      expect
-#      output
-#      untracked
-EOF
 test_expect_success 'commit --dry-run submodule summary (--amend)' '
+       cat >expect <<EOF &&
+On branch master
+Changes to be committed:
+  (use "git reset HEAD^1 <file>..." to unstage)
+
+       new file:   dir2/added
+       new file:   sm
+
+Changes not staged for commit:
+  (use "git add <file>..." to update what will be committed)
+  (use "git checkout -- <file>..." to discard changes in working directory)
+
+       modified:   dir1/modified
+
+Submodule changes to be committed:
+
+* sm 0000000...$head (1):
+  > Add foo
+
+Untracked files:
+  (use "git add <file>..." to include in what will be committed)
+
+       dir1/untracked
+       dir2/modified
+       dir2/untracked
+       untracked
+
+EOF
        git config status.submodulesummary 10 &&
        git commit --dry-run --amend >output &&
        test_i18ncmp expect output
@@ -1044,37 +1035,35 @@ test_expect_success POSIXPERM,SANITY 'status succeeds in a read-only repository'
 new_head=$(cd sm && git rev-parse --short=7 --verify HEAD)
 touch .gitmodules
 
-cat > expect << EOF
-# On branch master
-# Changes to be committed:
-#   (use "git reset HEAD <file>..." to unstage)
-#
-#      modified:   sm
-#
-# Changes not staged for commit:
-#   (use "git add <file>..." to update what will be committed)
-#   (use "git checkout -- <file>..." to discard changes in working directory)
-#
-#      modified:   dir1/modified
-#
-# Submodule changes to be committed:
-#
-# * sm $head...$new_head (1):
-#   > Add bar
-#
-# Untracked files:
-#   (use "git add <file>..." to include in what will be committed)
-#
-#      .gitmodules
-#      dir1/untracked
-#      dir2/modified
-#      dir2/untracked
-#      expect
-#      output
-#      untracked
-EOF
-
 test_expect_success '--ignore-submodules=untracked suppresses submodules with untracked content' '
+       cat > expect << EOF &&
+On branch master
+Changes to be committed:
+  (use "git reset HEAD <file>..." to unstage)
+
+       modified:   sm
+
+Changes not staged for commit:
+  (use "git add <file>..." to update what will be committed)
+  (use "git checkout -- <file>..." to discard changes in working directory)
+
+       modified:   dir1/modified
+
+Submodule changes to be committed:
+
+* sm $head...$new_head (1):
+  > Add bar
+
+Untracked files:
+  (use "git add <file>..." to include in what will be committed)
+
+       .gitmodules
+       dir1/untracked
+       dir2/modified
+       dir2/untracked
+       untracked
+
+EOF
        echo modified  sm/untracked &&
        git status --ignore-submodules=untracked >output &&
        test_i18ncmp expect output
@@ -1154,39 +1143,37 @@ test_expect_success '.git/config ignore=dirty suppresses submodules with modifie
        git config -f .gitmodules  --remove-section submodule.subname
 '
 
-cat > expect << EOF
-# On branch master
-# Changes to be committed:
-#   (use "git reset HEAD <file>..." to unstage)
-#
-#      modified:   sm
-#
-# Changes not staged for commit:
-#   (use "git add <file>..." to update what will be committed)
-#   (use "git checkout -- <file>..." to discard changes in working directory)
-#   (commit or discard the untracked or modified content in submodules)
-#
-#      modified:   dir1/modified
-#      modified:   sm (modified content)
-#
-# Submodule changes to be committed:
-#
-# * sm $head...$new_head (1):
-#   > Add bar
-#
-# Untracked files:
-#   (use "git add <file>..." to include in what will be committed)
-#
-#      .gitmodules
-#      dir1/untracked
-#      dir2/modified
-#      dir2/untracked
-#      expect
-#      output
-#      untracked
-EOF
-
 test_expect_success "--ignore-submodules=untracked doesn't suppress submodules with modified content" '
+       cat > expect << EOF &&
+On branch master
+Changes to be committed:
+  (use "git reset HEAD <file>..." to unstage)
+
+       modified:   sm
+
+Changes not staged for commit:
+  (use "git add <file>..." to update what will be committed)
+  (use "git checkout -- <file>..." to discard changes in working directory)
+  (commit or discard the untracked or modified content in submodules)
+
+       modified:   dir1/modified
+       modified:   sm (modified content)
+
+Submodule changes to be committed:
+
+* sm $head...$new_head (1):
+  > Add bar
+
+Untracked files:
+  (use "git add <file>..." to include in what will be committed)
+
+       .gitmodules
+       dir1/untracked
+       dir2/modified
+       dir2/untracked
+       untracked
+
+EOF
        git status --ignore-submodules=untracked > output &&
        test_i18ncmp expect output
 '
@@ -1212,43 +1199,41 @@ test_expect_success ".git/config ignore=untracked doesn't suppress submodules wi
 
 head2=$(cd sm && git commit -q -m "2nd commit" foo && git rev-parse --short=7 --verify HEAD)
 
-cat > expect << EOF
-# On branch master
-# Changes to be committed:
-#   (use "git reset HEAD <file>..." to unstage)
-#
-#      modified:   sm
-#
-# Changes not staged for commit:
-#   (use "git add <file>..." to update what will be committed)
-#   (use "git checkout -- <file>..." to discard changes in working directory)
-#
-#      modified:   dir1/modified
-#      modified:   sm (new commits)
-#
-# Submodule changes to be committed:
-#
-# * sm $head...$new_head (1):
-#   > Add bar
-#
-# Submodules changed but not updated:
-#
-# * sm $new_head...$head2 (1):
-#   > 2nd commit
-#
-# Untracked files:
-#   (use "git add <file>..." to include in what will be committed)
-#
-#      .gitmodules
-#      dir1/untracked
-#      dir2/modified
-#      dir2/untracked
-#      expect
-#      output
-#      untracked
-EOF
-
 test_expect_success "--ignore-submodules=untracked doesn't suppress submodule summary" '
+       cat > expect << EOF &&
+On branch master
+Changes to be committed:
+  (use "git reset HEAD <file>..." to unstage)
+
+       modified:   sm
+
+Changes not staged for commit:
+  (use "git add <file>..." to update what will be committed)
+  (use "git checkout -- <file>..." to discard changes in working directory)
+
+       modified:   dir1/modified
+       modified:   sm (new commits)
+
+Submodule changes to be committed:
+
+* sm $head...$new_head (1):
+  > Add bar
+
+Submodules changed but not updated:
+
+* sm $new_head...$head2 (1):
+  > 2nd commit
+
+Untracked files:
+  (use "git add <file>..." to include in what will be committed)
+
+       .gitmodules
+       dir1/untracked
+       dir2/modified
+       dir2/untracked
+       untracked
+
+EOF
        git status --ignore-submodules=untracked > output &&
        test_i18ncmp expect output
 '
@@ -1326,64 +1311,83 @@ cat > expect << EOF
 ;      dir1/untracked
 ;      dir2/modified
 ;      dir2/untracked
-;      expect
-;      output
 ;      untracked
+;
 EOF
 
 test_expect_success "status (core.commentchar with submodule summary)" '
        test_config core.commentchar ";" &&
-       git status >output &&
+       git -c status.displayCommentPrefix=true status >output &&
        test_i18ncmp expect output
 '
 
 test_expect_success "status (core.commentchar with two chars with submodule summary)" '
        test_config core.commentchar ";;" &&
-       git status >output &&
-       test_i18ncmp expect output
+       test_must_fail git -c status.displayCommentPrefix=true status
 '
 
-cat > expect << EOF
-# On branch master
-# Changes not staged for commit:
-#   (use "git add <file>..." to update what will be committed)
-#   (use "git checkout -- <file>..." to discard changes in working directory)
-#
-#      modified:   dir1/modified
-#
-# Untracked files:
-#   (use "git add <file>..." to include in what will be committed)
-#
-#      .gitmodules
-#      dir1/untracked
-#      dir2/modified
-#      dir2/untracked
-#      expect
-#      output
-#      untracked
+test_expect_success "--ignore-submodules=all suppresses submodule summary" '
+       cat > expect << EOF &&
+On branch master
+Changes not staged for commit:
+  (use "git add <file>..." to update what will be committed)
+  (use "git checkout -- <file>..." to discard changes in working directory)
+
+       modified:   dir1/modified
+
+Untracked files:
+  (use "git add <file>..." to include in what will be committed)
+
+       .gitmodules
+       dir1/untracked
+       dir2/modified
+       dir2/untracked
+       untracked
+
 no changes added to commit (use "git add" and/or "git commit -a")
 EOF
-
-test_expect_success "--ignore-submodules=all suppresses submodule summary" '
        git status --ignore-submodules=all > output &&
        test_i18ncmp expect output
 '
 
-test_expect_failure '.gitmodules ignore=all suppresses submodule summary' '
+test_expect_success '.gitmodules ignore=all suppresses unstaged submodule summary' '
+       cat > expect << EOF &&
+On branch master
+Changes to be committed:
+  (use "git reset HEAD <file>..." to unstage)
+
+       modified:   sm
+
+Changes not staged for commit:
+  (use "git add <file>..." to update what will be committed)
+  (use "git checkout -- <file>..." to discard changes in working directory)
+
+       modified:   dir1/modified
+
+Untracked files:
+  (use "git add <file>..." to include in what will be committed)
+
+       .gitmodules
+       dir1/untracked
+       dir2/modified
+       dir2/untracked
+       untracked
+
+EOF
        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 &&
+       test_i18ncmp 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 unstaged 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 &&
        git config --add submodule.subname.path sm &&
        git status > output &&
-       test_cmp expect output &&
+       test_i18ncmp expect output &&
        git config --remove-section submodule.subname &&
        git config -f .gitmodules  --remove-section submodule.subname
 '
@@ -1450,4 +1454,49 @@ test_expect_success 'Restore default test environment' '
        git config --unset status.showUntrackedFiles
 '
 
+test_expect_success 'git commit will commit a staged but ignored submodule' '
+       git config --add -f .gitmodules submodule.subname.ignore all &&
+       git config --add -f .gitmodules submodule.subname.path sm &&
+       git config --add submodule.subname.ignore all &&
+       git status -s --ignore-submodules=dirty >output &&
+       test_i18ngrep "^M. sm" output &&
+       GIT_EDITOR="echo hello >>\"\$1\"" &&
+       export GIT_EDITOR &&
+       git commit -uno &&
+       git status -s --ignore-submodules=dirty >output &&
+       test_i18ngrep ! "^M. sm" output
+'
+
+test_expect_success 'git commit --dry-run will show a staged but ignored submodule' '
+       git reset HEAD^ &&
+       git add sm &&
+       cat >expect << EOF &&
+On branch master
+Changes to be committed:
+  (use "git reset HEAD <file>..." to unstage)
+
+       modified:   sm
+
+Changes not staged for commit:
+  (use "git add <file>..." to update what will be committed)
+  (use "git checkout -- <file>..." to discard changes in working directory)
+
+       modified:   dir1/modified
+
+Untracked files not listed (use -u option to show untracked files)
+EOF
+       git commit -uno --dry-run >output &&
+       test_i18ncmp expect output &&
+       git status -s --ignore-submodules=dirty >output &&
+       test_i18ngrep "^M. sm" output
+'
+
+test_expect_success 'git commit -m will commit a staged but ignored submodule' '
+       git commit -uno -m message &&
+       git status -s --ignore-submodules=dirty >output &&
+        test_i18ngrep ! "^M. sm" output &&
+       git config --remove-section submodule.subname &&
+       git config -f .gitmodules  --remove-section submodule.subname
+'
+
 test_done