i18n: .git file is not a human readable message (t5601)
[gitweb.git] / t / t7508-status.sh
index c9300f3c8b246e3c81570532534748e510a2865f..a93e70fac446f0b062abe9109658d54b7c321819 100755 (executable)
@@ -7,6 +7,30 @@ test_description='git status'
 
 . ./test-lib.sh
 
+test_expect_success 'status -h in broken repository' '
+       mkdir broken &&
+       test_when_finished "rm -fr broken" &&
+       (
+               cd broken &&
+               git init &&
+               echo "[status] showuntrackedfiles = CORRUPT" >>.git/config &&
+               test_expect_code 129 git status -h >usage 2>&1
+       ) &&
+       grep "[Uu]sage" broken/usage
+'
+
+test_expect_success 'commit -h in broken repository' '
+       mkdir broken &&
+       test_when_finished "rm -fr broken" &&
+       (
+               cd broken &&
+               git init &&
+               echo "[status] showuntrackedfiles = CORRUPT" >>.git/config &&
+               test_expect_code 129 git commit -h >usage 2>&1
+       ) &&
+       grep "[Uu]sage" broken/usage
+'
+
 test_expect_success 'setup' '
        : >tracked &&
        : >modified &&
@@ -31,7 +55,7 @@ test_expect_success 'setup' '
        git add dir2/added
 '
 
-test_expect_success 'status (1)' '
+test_expect_success C_LOCALE_OUTPUT 'status (1)' '
 
        grep "use \"git rm --cached <file>\.\.\.\" to unstage" output
 
@@ -44,7 +68,7 @@ cat >expect <<\EOF
 #
 #      new file:   dir2/added
 #
-# Changed but not updated:
+# 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)
 #
@@ -61,7 +85,7 @@ cat >expect <<\EOF
 #      untracked
 EOF
 
-test_expect_success 'status (2)' '
+test_expect_success C_LOCALE_OUTPUT 'status (2)' '
 
        git status >output &&
        test_cmp expect output
@@ -73,7 +97,7 @@ cat >expect <<\EOF
 # Changes to be committed:
 #      new file:   dir2/added
 #
-# Changed but not updated:
+# Changes not staged for commit:
 #      modified:   dir1/modified
 #
 # Untracked files:
@@ -87,7 +111,7 @@ EOF
 
 git config advice.statusHints false
 
-test_expect_success 'status (advice.statusHints false)' '
+test_expect_success C_LOCALE_OUTPUT 'status (advice.statusHints false)' '
 
        git status >output &&
        test_cmp expect output
@@ -133,6 +157,12 @@ test_expect_success 'status -s -b' '
 
 '
 
+test_expect_success 'setup dir3' '
+       mkdir dir3 &&
+       : >dir3/untracked1 &&
+       : >dir3/untracked2
+'
+
 cat >expect <<EOF
 # On branch master
 # Changes to be committed:
@@ -140,7 +170,7 @@ cat >expect <<EOF
 #
 #      new file:   dir2/added
 #
-# Changed but not updated:
+# 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)
 #
@@ -148,16 +178,14 @@ cat >expect <<EOF
 #
 # Untracked files not listed (use -u option to show untracked files)
 EOF
-test_expect_success 'status -uno' '
-       mkdir dir3 &&
-       : >dir3/untracked1 &&
-       : >dir3/untracked2 &&
+test_expect_success C_LOCALE_OUTPUT 'status -uno' '
        git status -uno >output &&
        test_cmp expect output
 '
 
-test_expect_success 'status (status.showUntrackedFiles no)' '
+test_expect_success C_LOCALE_OUTPUT 'status (status.showUntrackedFiles no)' '
        git config status.showuntrackedfiles no
+       test_when_finished "git config --unset status.showuntrackedfiles" &&
        git status >output &&
        test_cmp expect output
 '
@@ -167,13 +195,13 @@ cat >expect <<EOF
 # Changes to be committed:
 #      new file:   dir2/added
 #
-# Changed but not updated:
+# Changes not staged for commit:
 #      modified:   dir1/modified
 #
 # Untracked files not listed
 EOF
 git config advice.statusHints false
-test_expect_success 'status -uno (advice.statusHints false)' '
+test_expect_success C_LOCALE_OUTPUT 'status -uno (advice.statusHints false)' '
        git status -uno >output &&
        test_cmp expect output
 '
@@ -184,7 +212,6 @@ cat >expect << EOF
 A  dir2/added
 EOF
 test_expect_success 'status -s -uno' '
-       git config --unset status.showuntrackedfiles
        git status -s -uno >output &&
        test_cmp expect output
 '
@@ -202,7 +229,7 @@ cat >expect <<EOF
 #
 #      new file:   dir2/added
 #
-# Changed but not updated:
+# 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)
 #
@@ -219,13 +246,14 @@ cat >expect <<EOF
 #      output
 #      untracked
 EOF
-test_expect_success 'status -unormal' '
+test_expect_success C_LOCALE_OUTPUT 'status -unormal' '
        git status -unormal >output &&
        test_cmp expect output
 '
 
-test_expect_success 'status (status.showUntrackedFiles normal)' '
+test_expect_success C_LOCALE_OUTPUT 'status (status.showUntrackedFiles normal)' '
        git config status.showuntrackedfiles normal
+       test_when_finished "git config --unset status.showuntrackedfiles" &&
        git status >output &&
        test_cmp expect output
 '
@@ -242,7 +270,6 @@ A  dir2/added
 ?? untracked
 EOF
 test_expect_success 'status -s -unormal' '
-       git config --unset status.showuntrackedfiles
        git status -s -unormal >output &&
        test_cmp expect output
 '
@@ -260,7 +287,7 @@ cat >expect <<EOF
 #
 #      new file:   dir2/added
 #
-# Changed but not updated:
+# 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)
 #
@@ -278,18 +305,21 @@ cat >expect <<EOF
 #      output
 #      untracked
 EOF
-test_expect_success 'status -uall' '
+test_expect_success C_LOCALE_OUTPUT 'status -uall' '
        git status -uall >output &&
        test_cmp expect output
 '
-test_expect_success 'status (status.showUntrackedFiles all)' '
+test_expect_success C_LOCALE_OUTPUT 'status (status.showUntrackedFiles all)' '
        git config status.showuntrackedfiles all
+       test_when_finished "git config --unset status.showuntrackedfiles" &&
        git status >output &&
-       rm -rf dir3 &&
-       git config --unset status.showuntrackedfiles &&
        test_cmp expect output
 '
 
+test_expect_success 'teardown dir3' '
+       rm -rf dir3
+'
+
 cat >expect <<EOF
  M dir1/modified
 A  dir2/added
@@ -320,7 +350,7 @@ cat >expect <<\EOF
 #
 #      new file:   ../dir2/added
 #
-# Changed but not updated:
+# 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)
 #
@@ -337,7 +367,7 @@ cat >expect <<\EOF
 #      ../untracked
 EOF
 
-test_expect_success 'status with relative paths' '
+test_expect_success C_LOCALE_OUTPUT 'status with relative paths' '
 
        (cd dir1 && git status) >output &&
        test_cmp expect output
@@ -381,18 +411,19 @@ test_expect_success 'status --porcelain ignores relative paths setting' '
 
 test_expect_success 'setup unique colors' '
 
-       git config status.color.untracked blue
+       git config status.color.untracked blue &&
+       git config status.color.branch green
 
 '
 
 cat >expect <<\EOF
-# On branch master
+# On branch <GREEN>master<RESET>
 # Changes to be committed:
 #   (use "git reset HEAD <file>..." to unstage)
 #
 #      <GREEN>new file:   dir2/added<RESET>
 #
-# Changed but not updated:
+# 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)
 #
@@ -409,18 +440,19 @@ cat >expect <<\EOF
 #      <BLUE>untracked<RESET>
 EOF
 
-test_expect_success 'status with color.ui' '
+test_expect_success C_LOCALE_OUTPUT 'status with color.ui' '
 
        git config color.ui always &&
+       test_when_finished "git config --unset color.ui" &&
        git status | test_decode_color >output &&
        test_cmp expect output
 
 '
 
-test_expect_success 'status with color.status' '
+test_expect_success C_LOCALE_OUTPUT 'status with color.status' '
 
-       git config --unset color.ui &&
        git config color.status always &&
+       test_when_finished "git config --unset color.status" &&
        git status | test_decode_color >output &&
        test_cmp expect output
 
@@ -439,7 +471,6 @@ EOF
 
 test_expect_success 'status -s with color.ui' '
 
-       git config --unset color.status &&
        git config color.ui always &&
        git status -s | test_decode_color >output &&
        test_cmp expect output
@@ -521,7 +552,7 @@ cat >expect <<\EOF
 #
 #      new file:   dir2/added
 #
-# Changed but not updated:
+# 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)
 #
@@ -539,9 +570,10 @@ cat >expect <<\EOF
 EOF
 
 
-test_expect_success 'status without relative paths' '
+test_expect_success C_LOCALE_OUTPUT 'status without relative paths' '
 
-       git config status.relativePaths false
+       git config status.relativePaths false &&
+       test_when_finished "git config --unset status.relativePaths" &&
        (cd dir1 && git status) >output &&
        test_cmp expect output
 
@@ -560,6 +592,8 @@ EOF
 
 test_expect_success 'status -s without relative paths' '
 
+       git config status.relativePaths false &&
+       test_when_finished "git config --unset status.relativePaths" &&
        (cd dir1 && git status -s) >output &&
        test_cmp expect output
 
@@ -582,7 +616,10 @@ cat <<EOF >expect
 #      untracked
 EOF
 test_expect_success 'dry-run of partial commit excluding new file in index' '
-       git commit --dry-run dir1/modified >output &&
+       git commit --dry-run dir1/modified >output
+'
+
+test_expect_success C_LOCALE_OUTPUT 'dry-run of partial commit excluding new file in index: output' '
        test_cmp expect output
 '
 
@@ -614,7 +651,7 @@ cat >expect <<EOF
 #      new file:   dir2/added
 #      new file:   sm
 #
-# Changed but not updated:
+# 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)
 #
@@ -630,13 +667,13 @@ cat >expect <<EOF
 #      output
 #      untracked
 EOF
-test_expect_success 'status submodule summary is disabled by default' '
+test_expect_success C_LOCALE_OUTPUT 'status submodule summary is disabled by default' '
        git status >output &&
        test_cmp expect output
 '
 
 # we expect the same as the previous test
-test_expect_success 'status --untracked-files=all does not show submodule' '
+test_expect_success C_LOCALE_OUTPUT 'status --untracked-files=all does not show submodule' '
        git status --untracked-files=all >output &&
        test_cmp expect output
 '
@@ -673,7 +710,7 @@ cat >expect <<EOF
 #      new file:   dir2/added
 #      new file:   sm
 #
-# Changed but not updated:
+# 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)
 #
@@ -694,7 +731,7 @@ cat >expect <<EOF
 #      output
 #      untracked
 EOF
-test_expect_success 'status submodule summary' '
+test_expect_success C_LOCALE_OUTPUT 'status submodule summary' '
        git config status.submodulesummary 10 &&
        git status >output &&
        test_cmp expect output
@@ -718,7 +755,7 @@ test_expect_success 'status -s submodule summary' '
 
 cat >expect <<EOF
 # On branch master
-# Changed but not updated:
+# 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)
 #
@@ -735,8 +772,11 @@ cat >expect <<EOF
 #      untracked
 no changes added to commit (use "git add" and/or "git commit -a")
 EOF
-test_expect_success 'status submodule summary (clean submodule)' '
-       git commit -m "commit submodule" &&
+test_expect_success 'status submodule summary (clean submodule): commit' '
+       git commit -m "commit submodule"
+'
+
+test_expect_success C_LOCALE_OUTPUT 'status submodule summary (clean submodule): output' '
        git config status.submodulesummary 10 &&
        test_must_fail git commit --dry-run >output &&
        test_cmp expect output &&
@@ -766,7 +806,7 @@ cat >expect <<EOF
 #      new file:   dir2/added
 #      new file:   sm
 #
-# Changed but not updated:
+# 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)
 #
@@ -787,7 +827,7 @@ cat >expect <<EOF
 #      output
 #      untracked
 EOF
-test_expect_success 'commit --dry-run submodule summary (--amend)' '
+test_expect_success C_LOCALE_OUTPUT 'commit --dry-run submodule summary (--amend)' '
        git config status.submodulesummary 10 &&
        git commit --dry-run --amend >output &&
        test_cmp expect output
@@ -819,7 +859,7 @@ cat > expect << EOF
 #
 #      modified:   sm
 #
-# Changed but not updated:
+# 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)
 #
@@ -842,13 +882,13 @@ cat > expect << EOF
 #      untracked
 EOF
 
-test_expect_success '--ignore-submodules=untracked suppresses submodules with untracked content' '
+test_expect_success C_LOCALE_OUTPUT '--ignore-submodules=untracked suppresses submodules with untracked content' '
        echo modified > sm/untracked &&
        git status --ignore-submodules=untracked > output &&
        test_cmp expect output
 '
 
-test_expect_success '.gitmodules ignore=untracked suppresses submodules with untracked content' '
+test_expect_success C_LOCALE_OUTPUT '.gitmodules ignore=untracked suppresses submodules with untracked content' '
        git config diff.ignoreSubmodules dirty &&
        git status >output &&
        test_cmp expect output &&
@@ -860,7 +900,7 @@ test_expect_success '.gitmodules ignore=untracked suppresses submodules with unt
        git config --unset diff.ignoreSubmodules
 '
 
-test_expect_success '.git/config ignore=untracked suppresses submodules with untracked content' '
+test_expect_success C_LOCALE_OUTPUT '.git/config ignore=untracked suppresses submodules with untracked content' '
        git config --add -f .gitmodules submodule.subname.ignore none &&
        git config --add -f .gitmodules submodule.subname.path sm &&
        git config --add submodule.subname.ignore untracked &&
@@ -871,12 +911,12 @@ test_expect_success '.git/config ignore=untracked suppresses submodules with unt
        git config --remove-section -f .gitmodules submodule.subname
 '
 
-test_expect_success '--ignore-submodules=dirty suppresses submodules with untracked content' '
+test_expect_success C_LOCALE_OUTPUT '--ignore-submodules=dirty suppresses submodules with untracked content' '
        git status --ignore-submodules=dirty > output &&
        test_cmp expect output
 '
 
-test_expect_success '.gitmodules ignore=dirty suppresses submodules with untracked content' '
+test_expect_success C_LOCALE_OUTPUT '.gitmodules ignore=dirty suppresses submodules with untracked content' '
        git config diff.ignoreSubmodules dirty &&
        git status >output &&
        ! test -s actual &&
@@ -888,7 +928,7 @@ test_expect_success '.gitmodules ignore=dirty suppresses submodules with untrack
        git config --unset diff.ignoreSubmodules
 '
 
-test_expect_success '.git/config ignore=dirty suppresses submodules with untracked content' '
+test_expect_success C_LOCALE_OUTPUT '.git/config ignore=dirty suppresses submodules with untracked content' '
        git config --add -f .gitmodules submodule.subname.ignore none &&
        git config --add -f .gitmodules submodule.subname.path sm &&
        git config --add submodule.subname.ignore dirty &&
@@ -899,13 +939,13 @@ test_expect_success '.git/config ignore=dirty suppresses submodules with untrack
        git config -f .gitmodules  --remove-section submodule.subname
 '
 
-test_expect_success '--ignore-submodules=dirty suppresses submodules with modified content' '
+test_expect_success C_LOCALE_OUTPUT '--ignore-submodules=dirty suppresses submodules with modified content' '
        echo modified > sm/foo &&
        git status --ignore-submodules=dirty > output &&
        test_cmp expect output
 '
 
-test_expect_success '.gitmodules ignore=dirty suppresses submodules with modified content' '
+test_expect_success C_LOCALE_OUTPUT '.gitmodules ignore=dirty suppresses submodules with modified content' '
        git config --add -f .gitmodules submodule.subname.ignore dirty &&
        git config --add -f .gitmodules submodule.subname.path sm &&
        git status > output &&
@@ -913,7 +953,7 @@ test_expect_success '.gitmodules ignore=dirty suppresses submodules with modifie
        git config -f .gitmodules  --remove-section submodule.subname
 '
 
-test_expect_success '.git/config ignore=dirty suppresses submodules with modified content' '
+test_expect_success C_LOCALE_OUTPUT '.git/config ignore=dirty suppresses submodules with modified content' '
        git config --add -f .gitmodules submodule.subname.ignore none &&
        git config --add -f .gitmodules submodule.subname.path sm &&
        git config --add submodule.subname.ignore dirty &&
@@ -931,7 +971,7 @@ cat > expect << EOF
 #
 #      modified:   sm
 #
-# Changed but not updated:
+# 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)
@@ -956,12 +996,12 @@ cat > expect << EOF
 #      untracked
 EOF
 
-test_expect_success "--ignore-submodules=untracked doesn't suppress submodules with modified content" '
+test_expect_success C_LOCALE_OUTPUT "--ignore-submodules=untracked doesn't suppress submodules with modified content" '
        git status --ignore-submodules=untracked > output &&
        test_cmp expect output
 '
 
-test_expect_success ".gitmodules ignore=untracked doesn't suppress submodules with modified content" '
+test_expect_success C_LOCALE_OUTPUT ".gitmodules ignore=untracked doesn't suppress submodules with modified content" '
        git config --add -f .gitmodules submodule.subname.ignore untracked &&
        git config --add -f .gitmodules submodule.subname.path sm &&
        git status > output &&
@@ -969,7 +1009,7 @@ test_expect_success ".gitmodules ignore=untracked doesn't suppress submodules wi
        git config -f .gitmodules  --remove-section submodule.subname
 '
 
-test_expect_success ".git/config ignore=untracked doesn't suppress submodules with modified content" '
+test_expect_success C_LOCALE_OUTPUT ".git/config ignore=untracked doesn't suppress submodules with modified content" '
        git config --add -f .gitmodules submodule.subname.ignore none &&
        git config --add -f .gitmodules submodule.subname.path sm &&
        git config --add submodule.subname.ignore untracked &&
@@ -989,7 +1029,7 @@ cat > expect << EOF
 #
 #      modified:   sm
 #
-# Changed but not updated:
+# 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)
 #
@@ -1018,12 +1058,12 @@ cat > expect << EOF
 #      untracked
 EOF
 
-test_expect_success "--ignore-submodules=untracked doesn't suppress submodule summary" '
+test_expect_success C_LOCALE_OUTPUT "--ignore-submodules=untracked doesn't suppress submodule summary" '
        git status --ignore-submodules=untracked > output &&
        test_cmp expect output
 '
 
-test_expect_success ".gitmodules ignore=untracked doesn't suppress submodule summary" '
+test_expect_success C_LOCALE_OUTPUT ".gitmodules ignore=untracked doesn't suppress submodule summary" '
        git config --add -f .gitmodules submodule.subname.ignore untracked &&
        git config --add -f .gitmodules submodule.subname.path sm &&
        git status > output &&
@@ -1031,7 +1071,7 @@ test_expect_success ".gitmodules ignore=untracked doesn't suppress submodule sum
        git config -f .gitmodules  --remove-section submodule.subname
 '
 
-test_expect_success ".git/config ignore=untracked doesn't suppress submodule summary" '
+test_expect_success C_LOCALE_OUTPUT ".git/config ignore=untracked doesn't suppress 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 untracked &&
@@ -1042,11 +1082,11 @@ test_expect_success ".git/config ignore=untracked doesn't suppress submodule sum
        git config -f .gitmodules  --remove-section submodule.subname
 '
 
-test_expect_success "--ignore-submodules=dirty doesn't suppress submodule summary" '
+test_expect_success C_LOCALE_OUTPUT "--ignore-submodules=dirty doesn't suppress submodule summary" '
        git status --ignore-submodules=dirty > output &&
        test_cmp expect output
 '
-test_expect_success ".gitmodules ignore=dirty doesn't suppress submodule summary" '
+test_expect_success C_LOCALE_OUTPUT ".gitmodules ignore=dirty doesn't suppress submodule summary" '
        git config --add -f .gitmodules submodule.subname.ignore dirty &&
        git config --add -f .gitmodules submodule.subname.path sm &&
        git status > output &&
@@ -1054,7 +1094,7 @@ test_expect_success ".gitmodules ignore=dirty doesn't suppress submodule summary
        git config -f .gitmodules  --remove-section submodule.subname
 '
 
-test_expect_success ".git/config ignore=dirty doesn't suppress submodule summary" '
+test_expect_success C_LOCALE_OUTPUT ".git/config ignore=dirty doesn't suppress 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 dirty &&
@@ -1067,7 +1107,7 @@ test_expect_success ".git/config ignore=dirty doesn't suppress submodule summary
 
 cat > expect << EOF
 # On branch master
-# Changed but not updated:
+# 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)
 #
@@ -1086,7 +1126,7 @@ cat > expect << EOF
 no changes added to commit (use "git add" and/or "git commit -a")
 EOF
 
-test_expect_success "--ignore-submodules=all suppresses submodule summary" '
+test_expect_success C_LOCALE_OUTPUT "--ignore-submodules=all suppresses submodule summary" '
        git status --ignore-submodules=all > output &&
        test_cmp expect output
 '