diff options
Diffstat (limited to 't/t7508-status.sh')
-rwxr-xr-x | t/t7508-status.sh | 213 |
1 files changed, 126 insertions, 87 deletions
diff --git a/t/t7508-status.sh b/t/t7508-status.sh index 4e676cdce8..05c6c02435 100755 --- a/t/t7508-status.sh +++ b/t/t7508-status.sh @@ -37,11 +37,11 @@ test_expect_success 'create upstream branch' ' git checkout -b upstream && test_commit upstream1 && test_commit upstream2 && - # leave the first commit on master as root because several + # leave the first commit on main as root because several # tests depend on this case; for our upstream we only # care about commit counts anyway, so a totally divergent # history is OK - git checkout --orphan master + git checkout --orphan main ' test_expect_success 'setup' ' @@ -88,7 +88,7 @@ EOF test_expect_success 'status --column' ' cat >expect <<\EOF && -# On branch master +# On branch main # Your branch and '\''upstream'\'' have diverged, # and have 1 and 2 different commits each, respectively. # (use "git pull" to merge the remote branch into yours) @@ -109,17 +109,17 @@ test_expect_success 'status --column' ' # EOF COLUMNS=50 git -c status.displayCommentPrefix=true status --column="column dense" >output && - test_i18ncmp expect output + test_cmp expect output ' test_expect_success 'status --column status.displayCommentPrefix=false' ' strip_comments expect && COLUMNS=49 git -c status.displayCommentPrefix=false status --column="column dense" >output && - test_i18ncmp expect output + test_cmp expect output ' cat >expect <<\EOF -# On branch master +# On branch main # Your branch and 'upstream' have diverged, # and have 1 and 2 different commits each, respectively. # (use "git pull" to merge the remote branch into yours) @@ -144,19 +144,19 @@ EOF test_expect_success 'status with status.displayCommentPrefix=true' ' git -c status.displayCommentPrefix=true status >output && - test_i18ncmp expect output + test_cmp expect output ' test_expect_success 'status with status.displayCommentPrefix=false' ' strip_comments expect && git -c status.displayCommentPrefix=false status >output && - test_i18ncmp expect output + test_cmp 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_cmp expect-with-v output ' test_expect_success 'status -v -v' ' @@ -167,7 +167,7 @@ test_expect_success 'status -v -v' ' 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_cmp expect-with-v output ' test_expect_success 'setup fake editor' ' @@ -193,7 +193,7 @@ test_expect_success 'commit ignores status.displayCommentPrefix=false in COMMIT_ ' cat >expect <<\EOF -On branch master +On branch main Your branch and 'upstream' have diverged, and have 1 and 2 different commits each, respectively. @@ -214,7 +214,7 @@ EOF test_expect_success 'status (advice.statusHints false)' ' test_config advice.statusHints false && git status >output && - test_i18ncmp expect output + test_cmp expect output ' @@ -266,7 +266,7 @@ test_expect_success 'status with gitignore' ' test_cmp expect output && cat >expect <<\EOF && -On branch master +On branch main Your branch and '\''upstream'\'' have diverged, and have 1 and 2 different commits each, respectively. (use "git pull" to merge the remote branch into yours) @@ -296,7 +296,7 @@ Ignored files: EOF git status --ignored >output && - test_i18ncmp expect output + test_cmp expect output ' test_expect_success 'status with gitignore (nothing untracked)' ' @@ -331,7 +331,7 @@ test_expect_success 'status with gitignore (nothing untracked)' ' test_cmp expect output && cat >expect <<\EOF && -On branch master +On branch main Your branch and '\''upstream'\'' have diverged, and have 1 and 2 different commits each, respectively. (use "git pull" to merge the remote branch into yours) @@ -358,7 +358,7 @@ Ignored files: EOF git status --ignored >output && - test_i18ncmp expect output + test_cmp expect output ' cat >.gitignore <<\EOF @@ -368,7 +368,7 @@ output* EOF cat >expect <<\EOF -## master...upstream [ahead 1, behind 2] +## main...upstream [ahead 1, behind 2] M dir1/modified A dir2/added ?? dir1/untracked @@ -380,7 +380,7 @@ EOF test_expect_success 'status -s -b' ' git status -s -b >output && - test_i18ncmp expect output + test_cmp expect output ' @@ -390,7 +390,7 @@ test_expect_success 'status -s -z -b' ' git status -s -z -b >output && nul_to_q <output >output.q && mv output.q output && - test_i18ncmp expect output + test_cmp expect output ' test_expect_success 'setup dir3' ' @@ -401,7 +401,7 @@ test_expect_success 'setup dir3' ' test_expect_success 'status -uno' ' cat >expect <<EOF && -On branch master +On branch main Your branch and '\''upstream'\'' have diverged, and have 1 and 2 different commits each, respectively. (use "git pull" to merge the remote branch into yours) @@ -418,18 +418,18 @@ Changes not staged for commit: Untracked files not listed (use -u option to show untracked files) EOF git status -uno >output && - test_i18ncmp expect output + test_cmp expect output ' test_expect_success 'status (status.showUntrackedFiles no)' ' test_config status.showuntrackedfiles no && git status >output && - test_i18ncmp expect output + test_cmp expect output ' test_expect_success 'status -uno (advice.statusHints false)' ' cat >expect <<EOF && -On branch master +On branch main Your branch and '\''upstream'\'' have diverged, and have 1 and 2 different commits each, respectively. @@ -443,7 +443,7 @@ Untracked files not listed EOF test_config advice.statusHints false && git status -uno >output && - test_i18ncmp expect output + test_cmp expect output ' cat >expect << EOF @@ -463,7 +463,7 @@ test_expect_success 'status -s (status.showUntrackedFiles no)' ' test_expect_success 'status -unormal' ' cat >expect <<EOF && -On branch master +On branch main Your branch and '\''upstream'\'' have diverged, and have 1 and 2 different commits each, respectively. (use "git pull" to merge the remote branch into yours) @@ -487,13 +487,13 @@ Untracked files: EOF git status -unormal >output && - test_i18ncmp expect output + test_cmp expect output ' test_expect_success 'status (status.showUntrackedFiles normal)' ' test_config status.showuntrackedfiles normal && git status >output && - test_i18ncmp expect output + test_cmp expect output ' cat >expect <<EOF @@ -518,7 +518,7 @@ test_expect_success 'status -s (status.showUntrackedFiles normal)' ' test_expect_success 'status -uall' ' cat >expect <<EOF && -On branch master +On branch main Your branch and '\''upstream'\'' have diverged, and have 1 and 2 different commits each, respectively. (use "git pull" to merge the remote branch into yours) @@ -543,13 +543,13 @@ Untracked files: EOF git status -uall >output && - test_i18ncmp expect output + test_cmp expect output ' test_expect_success 'status (status.showUntrackedFiles all)' ' test_config status.showuntrackedfiles all && git status >output && - test_i18ncmp expect output + test_cmp expect output ' test_expect_success 'teardown dir3' ' @@ -578,7 +578,7 @@ test_expect_success 'status -s (status.showUntrackedFiles all)' ' test_expect_success 'status with relative paths' ' cat >expect <<\EOF && -On branch master +On branch main Your branch and '\''upstream'\'' have diverged, and have 1 and 2 different commits each, respectively. (use "git pull" to merge the remote branch into yours) @@ -601,7 +601,7 @@ Untracked files: EOF (cd dir1 && git status) >output && - test_i18ncmp expect output + test_cmp expect output ' cat >expect <<\EOF @@ -646,7 +646,7 @@ test_expect_success 'setup unique colors' ' test_expect_success TTY 'status with color.ui' ' cat >expect <<\EOF && -On branch <GREEN>master<RESET> +On branch <GREEN>main<RESET> Your branch and '\''upstream'\'' have diverged, and have 1 and 2 different commits each, respectively. (use "git pull" to merge the remote branch into yours) @@ -670,13 +670,13 @@ Untracked files: EOF test_config color.ui auto && test_terminal git status | test_decode_color >output && - test_i18ncmp expect output + test_cmp expect output ' test_expect_success TTY 'status with color.status' ' test_config color.status auto && test_terminal git status | test_decode_color >output && - test_i18ncmp expect output + test_cmp expect output ' cat >expect <<\EOF @@ -706,7 +706,7 @@ test_expect_success TTY 'status -s with color.status' ' ' cat >expect <<\EOF -## <YELLOW>master<RESET>...<CYAN>upstream<RESET> [ahead <YELLOW>1<RESET>, behind <CYAN>2<RESET>] +## <YELLOW>main<RESET>...<CYAN>upstream<RESET> [ahead <YELLOW>1<RESET>, behind <CYAN>2<RESET>] <RED>M<RESET> dir1/modified <GREEN>A<RESET> dir2/added <BLUE>??<RESET> dir1/untracked @@ -718,7 +718,7 @@ EOF test_expect_success TTY 'status -s -b with color.status' ' test_terminal git status -s -b | test_decode_color >output && - test_i18ncmp expect output + test_cmp expect output ' @@ -757,7 +757,7 @@ test_expect_success 'status --porcelain respects -b' ' git status --porcelain -b >output && { - echo "## master...upstream [ahead 1, behind 2]" && + echo "## main...upstream [ahead 1, behind 2]" && cat expect } >tmp && mv tmp expect && @@ -769,7 +769,7 @@ test_expect_success 'status --porcelain respects -b' ' test_expect_success 'status without relative paths' ' cat >expect <<\EOF && -On branch master +On branch main Your branch and '\''upstream'\'' have diverged, and have 1 and 2 different commits each, respectively. (use "git pull" to merge the remote branch into yours) @@ -793,7 +793,7 @@ Untracked files: EOF test_config status.relativePaths false && (cd dir1 && git status) >output && - test_i18ncmp expect output + test_cmp expect output ' @@ -814,9 +814,36 @@ test_expect_success 'status -s without relative paths' ' ' +cat >expect <<\EOF + M dir1/modified +A dir2/added +A "file with spaces" +?? dir1/untracked +?? dir2/modified +?? dir2/untracked +?? "file with spaces 2" +?? untracked +EOF + +test_expect_success 'status -s without relative paths' ' + test_when_finished "git rm --cached \"file with spaces\"; rm -f file*" && + >"file with spaces" && + >"file with spaces 2" && + >"expect with spaces" && + git add "file with spaces" && + + git status -s >output && + test_cmp expect output && + + git status -s --ignored >output && + grep "^!! \"expect with spaces\"$" output && + grep -v "^!! " output >output-wo-ignored && + test_cmp expect output-wo-ignored +' + test_expect_success 'dry-run of partial commit excluding new file in index' ' cat >expect <<EOF && -On branch master +On branch main Your branch and '\''upstream'\'' have diverged, and have 1 and 2 different commits each, respectively. (use "git pull" to merge the remote branch into yours) @@ -833,11 +860,11 @@ Untracked files: EOF git commit --dry-run dir1/modified >output && - test_i18ncmp expect output + test_cmp expect output ' cat >expect <<EOF -:100644 100644 $EMPTY_BLOB 0000000000000000000000000000000000000000 M dir1/modified +:100644 100644 $EMPTY_BLOB $ZERO_OID M dir1/modified EOF test_expect_success 'status refreshes the index' ' touch dir2/added && @@ -846,6 +873,18 @@ test_expect_success 'status refreshes the index' ' test_cmp expect output ' +test_expect_success 'status shows detached HEAD properly after checking out non-local upstream branch' ' + test_when_finished rm -rf upstream downstream actual && + + test_create_repo upstream && + test_commit -C upstream foo && + + git clone upstream downstream && + git -C downstream checkout @{u} && + git -C downstream status >actual && + grep -E "HEAD detached at [0-9a-f]+" actual +' + test_expect_success 'setup status submodule summary' ' test_create_repo sm && ( cd sm && @@ -858,7 +897,7 @@ test_expect_success 'setup status submodule summary' ' test_expect_success 'status submodule summary is disabled by default' ' cat >expect <<EOF && -On branch master +On branch main Your branch and '\''upstream'\'' have diverged, and have 1 and 2 different commits each, respectively. (use "git pull" to merge the remote branch into yours) @@ -882,13 +921,13 @@ Untracked files: EOF git status >output && - test_i18ncmp expect output + test_cmp expect output ' # we expect the same as the previous test test_expect_success 'status --untracked-files=all does not show submodule' ' git status --untracked-files=all >output && - test_i18ncmp expect output + test_cmp expect output ' cat >expect <<EOF @@ -915,7 +954,7 @@ head=$(cd sm && git rev-parse --short=7 --verify HEAD) test_expect_success 'status submodule summary' ' cat >expect <<EOF && -On branch master +On branch main Your branch and '\''upstream'\'' have diverged, and have 1 and 2 different commits each, respectively. (use "git pull" to merge the remote branch into yours) @@ -945,13 +984,13 @@ Untracked files: EOF git config status.submodulesummary 10 && git status >output && - test_i18ncmp expect output + test_cmp expect output ' test_expect_success 'status submodule summary with status.displayCommentPrefix=false' ' strip_comments expect && git -c status.displayCommentPrefix=false status >output && - test_i18ncmp expect output + test_cmp expect output ' test_expect_success 'commit with submodule summary ignores status.displayCommentPrefix' ' @@ -974,7 +1013,7 @@ test_expect_success 'status -s submodule summary' ' test_expect_success 'status submodule summary (clean submodule): commit' ' cat >expect <<EOF && -On branch master +On branch main Your branch and '\''upstream'\'' have diverged, and have 2 and 2 different commits each, respectively. (use "git pull" to merge the remote branch into yours) @@ -996,9 +1035,9 @@ EOF git commit -m "commit submodule" && git config status.submodulesummary 10 && test_must_fail git commit --dry-run >output && - test_i18ncmp expect output && + test_cmp expect output && git status >output && - test_i18ncmp expect output + test_cmp expect output ' cat >expect <<EOF @@ -1022,7 +1061,7 @@ test_expect_success 'status -z implies porcelain' ' test_expect_success 'commit --dry-run submodule summary (--amend)' ' cat >expect <<EOF && -On branch master +On branch main Your branch and '\''upstream'\'' have diverged, and have 2 and 2 different commits each, respectively. (use "git pull" to merge the remote branch into yours) @@ -1052,7 +1091,7 @@ Untracked files: EOF git config status.submodulesummary 10 && git commit --dry-run --amend >output && - test_i18ncmp expect output + test_cmp expect output ' test_expect_success POSIXPERM,SANITY 'status succeeds in a read-only repository' ' @@ -1074,7 +1113,7 @@ touch .gitmodules test_expect_success '--ignore-submodules=untracked suppresses submodules with untracked content' ' cat > expect << EOF && -On branch master +On branch main Your branch and '\''upstream'\'' have diverged, and have 2 and 2 different commits each, respectively. (use "git pull" to merge the remote branch into yours) @@ -1104,17 +1143,17 @@ Untracked files: EOF echo modified sm/untracked && git status --ignore-submodules=untracked >output && - test_i18ncmp expect output + test_cmp expect output ' test_expect_success '.gitmodules ignore=untracked suppresses submodules with untracked content' ' test_config diff.ignoreSubmodules dirty && git status >output && - test_i18ncmp expect output && + test_cmp expect output && git config --add -f .gitmodules submodule.subname.ignore untracked && git config --add -f .gitmodules submodule.subname.path sm && git status >output && - test_i18ncmp expect output && + test_cmp expect output && git config -f .gitmodules --remove-section submodule.subname ' @@ -1124,14 +1163,14 @@ test_expect_success '.git/config ignore=untracked suppresses submodules with unt git config --add submodule.subname.ignore untracked && git config --add submodule.subname.path sm && git status >output && - test_i18ncmp expect output && + test_cmp expect output && git config --remove-section submodule.subname && git config --remove-section -f .gitmodules submodule.subname ' test_expect_success '--ignore-submodules=dirty suppresses submodules with untracked content' ' git status --ignore-submodules=dirty >output && - test_i18ncmp expect output + test_cmp expect output ' test_expect_success '.gitmodules ignore=dirty suppresses submodules with untracked content' ' @@ -1141,7 +1180,7 @@ test_expect_success '.gitmodules ignore=dirty suppresses submodules with untrack git config --add -f .gitmodules submodule.subname.ignore dirty && git config --add -f .gitmodules submodule.subname.path sm && git status >output && - test_i18ncmp expect output && + test_cmp expect output && git config -f .gitmodules --remove-section submodule.subname ' @@ -1151,7 +1190,7 @@ test_expect_success '.git/config ignore=dirty suppresses submodules with untrack git config --add submodule.subname.ignore dirty && git config --add submodule.subname.path sm && git status >output && - test_i18ncmp expect output && + test_cmp expect output && git config --remove-section submodule.subname && git config -f .gitmodules --remove-section submodule.subname ' @@ -1159,14 +1198,14 @@ test_expect_success '.git/config ignore=dirty suppresses submodules with untrack test_expect_success '--ignore-submodules=dirty suppresses submodules with modified content' ' echo modified >sm/foo && git status --ignore-submodules=dirty >output && - test_i18ncmp expect output + test_cmp expect output ' test_expect_success '.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 && - test_i18ncmp expect output && + test_cmp expect output && git config -f .gitmodules --remove-section submodule.subname ' @@ -1176,14 +1215,14 @@ test_expect_success '.git/config ignore=dirty suppresses submodules with modifie git config --add submodule.subname.ignore dirty && git config --add submodule.subname.path sm && git status >output && - test_i18ncmp expect output && + test_cmp expect output && git config --remove-section submodule.subname && git config -f .gitmodules --remove-section submodule.subname ' test_expect_success "--ignore-submodules=untracked doesn't suppress submodules with modified content" ' cat > expect << EOF && -On branch master +On branch main Your branch and '\''upstream'\'' have diverged, and have 2 and 2 different commits each, respectively. (use "git pull" to merge the remote branch into yours) @@ -1214,14 +1253,14 @@ Untracked files: EOF git status --ignore-submodules=untracked > output && - test_i18ncmp expect output + test_cmp expect output ' test_expect_success ".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 && - test_i18ncmp expect output && + test_cmp expect output && git config -f .gitmodules --remove-section submodule.subname ' @@ -1231,7 +1270,7 @@ test_expect_success ".git/config ignore=untracked doesn't suppress submodules wi git config --add submodule.subname.ignore untracked && git config --add submodule.subname.path sm && git status >output && - test_i18ncmp expect output && + test_cmp expect output && git config --remove-section submodule.subname && git config -f .gitmodules --remove-section submodule.subname ' @@ -1240,7 +1279,7 @@ head2=$(cd sm && git commit -q -m "2nd commit" foo && git rev-parse --short=7 -- test_expect_success "--ignore-submodules=untracked doesn't suppress submodule summary" ' cat > expect << EOF && -On branch master +On branch main Your branch and '\''upstream'\'' have diverged, and have 2 and 2 different commits each, respectively. (use "git pull" to merge the remote branch into yours) @@ -1275,14 +1314,14 @@ Untracked files: EOF git status --ignore-submodules=untracked > output && - test_i18ncmp expect output + test_cmp expect output ' test_expect_success ".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 && - test_i18ncmp expect output && + test_cmp expect output && git config -f .gitmodules --remove-section submodule.subname ' @@ -1292,20 +1331,20 @@ test_expect_success ".git/config ignore=untracked doesn't suppress submodule sum git config --add submodule.subname.ignore untracked && git config --add submodule.subname.path sm && git status >output && - test_i18ncmp expect output && + test_cmp expect output && git config --remove-section submodule.subname && git config -f .gitmodules --remove-section submodule.subname ' test_expect_success "--ignore-submodules=dirty doesn't suppress submodule summary" ' git status --ignore-submodules=dirty > output && - test_i18ncmp expect output + test_cmp expect output ' test_expect_success ".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 && - test_i18ncmp expect output && + test_cmp expect output && git config -f .gitmodules --remove-section submodule.subname ' @@ -1315,13 +1354,13 @@ test_expect_success ".git/config ignore=dirty doesn't suppress submodule summary git config --add submodule.subname.ignore dirty && git config --add submodule.subname.path sm && git status >output && - test_i18ncmp expect output && + test_cmp expect output && git config --remove-section submodule.subname && git config -f .gitmodules --remove-section submodule.subname ' cat > expect << EOF -; On branch master +; On branch main ; Your branch and 'upstream' have diverged, ; and have 2 and 2 different commits each, respectively. ; (use "git pull" to merge the remote branch into yours) @@ -1359,7 +1398,7 @@ EOF test_expect_success "status (core.commentchar with submodule summary)" ' test_config core.commentchar ";" && git -c status.displayCommentPrefix=true status >output && - test_i18ncmp expect output + test_cmp expect output ' test_expect_success "status (core.commentchar with two chars with submodule summary)" ' @@ -1369,7 +1408,7 @@ test_expect_success "status (core.commentchar with two chars with submodule summ test_expect_success "--ignore-submodules=all suppresses submodule summary" ' cat > expect << EOF && -On branch master +On branch main Your branch and '\''upstream'\'' have diverged, and have 2 and 2 different commits each, respectively. (use "git pull" to merge the remote branch into yours) @@ -1390,12 +1429,12 @@ Untracked files: no changes added to commit (use "git add" and/or "git commit -a") EOF git status --ignore-submodules=all > output && - test_i18ncmp expect output + test_cmp expect output ' test_expect_success '.gitmodules ignore=all suppresses unstaged submodule summary' ' cat > expect << EOF && -On branch master +On branch main Your branch and '\''upstream'\'' have diverged, and have 2 and 2 different commits each, respectively. (use "git pull" to merge the remote branch into yours) @@ -1421,7 +1460,7 @@ EOF git config --add -f .gitmodules submodule.subname.ignore all && git config --add -f .gitmodules submodule.subname.path sm && git status > output && - test_i18ncmp expect output && + test_cmp expect output && git config -f .gitmodules --remove-section submodule.subname ' @@ -1431,7 +1470,7 @@ test_expect_success '.git/config ignore=all suppresses unstaged submodule summar git config --add submodule.subname.ignore all && git config --add submodule.subname.path sm && git status > output && - test_i18ncmp expect output && + test_cmp expect output && git config --remove-section submodule.subname && git config -f .gitmodules --remove-section submodule.subname ' @@ -1471,7 +1510,7 @@ test_expect_success '"status.branch=true" same as "-b"' ' test_expect_success '"status.branch=true" different from "--no-branch"' ' git status -s --no-branch >expected_nobranch && git -c status.branch=true status -s >actual && - test_must_fail test_cmp expected_nobranch actual + ! test_cmp expected_nobranch actual ' test_expect_success '"status.branch=true" weaker than "--no-branch"' ' @@ -1515,7 +1554,7 @@ test_expect_success 'git commit --dry-run will show a staged but ignored submodu git reset HEAD^ && git add sm && cat >expect << EOF && -On branch master +On branch main Your branch and '\''upstream'\'' have diverged, and have 2 and 2 different commits each, respectively. (use "git pull" to merge the remote branch into yours) @@ -1532,7 +1571,7 @@ Changes not staged for commit: Untracked files not listed (use -u option to show untracked files) EOF git commit -uno --dry-run >output && - test_i18ncmp expect output && + test_cmp expect output && git status -s --ignore-submodules=dirty >output && test_i18ngrep "^M. sm" output ' @@ -1571,7 +1610,7 @@ test_expect_success '"status.showStash=true" weaker than "--no-show-stash"' ' test_cmp expected_without_stash actual ' -test_expect_success 'no additionnal info if no stash entries' ' +test_expect_success 'no additional info if no stash entries' ' git stash clear && git -c status.showStash=true status >actual && test_cmp expected_without_stash actual |