diff options
author | Junio C Hamano <gitster@pobox.com> | 2020-10-30 13:04:24 -0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2020-10-30 13:04:24 -0700 |
commit | c8b7c0272aa67ce0788be51e3f0edb5f2279abb8 (patch) | |
tree | da0bdc0d519f509c890cbeb84e9bd635a8a5a736 | |
parent | Merge branch 'ct/t0000-use-test-path-is-file' (diff) | |
parent | t7102: prepare expected output inside test_expect_* block (diff) | |
download | tgif-c8b7c0272aa67ce0788be51e3f0edb5f2279abb8.tar.xz |
Merge branch 'cm/t7xxx-cleanup'
Micro clean-up.
* cm/t7xxx-cleanup:
t7102: prepare expected output inside test_expect_* block
t7201: put each command on a separate line
t7201: use 'git -C' to avoid subshell
t7102,t7201: remove whitespace after redirect operator
t7102,t7201: remove unnecessary blank spaces in test body
t7101,t7102,t7201: modernize test formatting
-rwxr-xr-x | t/t7101-reset-empty-subdirs.sh | 66 | ||||
-rwxr-xr-x | t/t7102-reset.sh | 307 | ||||
-rwxr-xr-x | t/t7201-co.sh | 102 |
3 files changed, 217 insertions, 258 deletions
diff --git a/t/t7101-reset-empty-subdirs.sh b/t/t7101-reset-empty-subdirs.sh index 96e163f084..bfce05ac5d 100755 --- a/t/t7101-reset-empty-subdirs.sh +++ b/t/t7101-reset-empty-subdirs.sh @@ -6,16 +6,15 @@ test_description='git reset should cull empty subdirs' . ./test-lib.sh -test_expect_success \ - 'creating initial files' \ - 'mkdir path0 && +test_expect_success 'creating initial files' ' + mkdir path0 && cp "$TEST_DIRECTORY"/../COPYING path0/COPYING && git add path0/COPYING && - git commit -m add -a' + git commit -m add -a +' -test_expect_success \ - 'creating second files' \ - 'mkdir path1 && +test_expect_success 'creating second files' ' + mkdir path1 && mkdir path1/path2 && cp "$TEST_DIRECTORY"/../COPYING path1/path2/COPYING && cp "$TEST_DIRECTORY"/../COPYING path1/COPYING && @@ -25,39 +24,40 @@ test_expect_success \ git add path1/COPYING && git add COPYING && git add path0/COPYING-TOO && - git commit -m change -a' + git commit -m change -a +' -test_expect_success \ - 'resetting tree HEAD^' \ - 'git reset --hard HEAD^' +test_expect_success 'resetting tree HEAD^' ' + git reset --hard HEAD^ +' -test_expect_success \ - 'checking initial files exist after rewind' \ - 'test -d path0 && - test -f path0/COPYING' +test_expect_success 'checking initial files exist after rewind' ' + test -d path0 && + test -f path0/COPYING +' -test_expect_success \ - 'checking lack of path1/path2/COPYING' \ - '! test -f path1/path2/COPYING' +test_expect_success 'checking lack of path1/path2/COPYING' ' + ! test -f path1/path2/COPYING +' -test_expect_success \ - 'checking lack of path1/COPYING' \ - '! test -f path1/COPYING' +test_expect_success 'checking lack of path1/COPYING' ' + ! test -f path1/COPYING +' -test_expect_success \ - 'checking lack of COPYING' \ - '! test -f COPYING' +test_expect_success 'checking lack of COPYING' ' + ! test -f COPYING +' -test_expect_success \ - 'checking checking lack of path1/COPYING-TOO' \ - '! test -f path0/COPYING-TOO' +test_expect_success 'checking checking lack of path1/COPYING-TOO' ' + ! test -f path0/COPYING-TOO +' -test_expect_success \ - 'checking lack of path1/path2' \ - '! test -d path1/path2' +test_expect_success 'checking lack of path1/path2' ' + ! test -d path1/path2 +' -test_expect_success \ - 'checking lack of path1' \ - '! test -d path1' +test_expect_success 'checking lack of path1' ' + ! test -d path1 +' test_done diff --git a/t/t7102-reset.sh b/t/t7102-reset.sh index 22161b3b2d..b1affb001f 100755 --- a/t/t7102-reset.sh +++ b/t/t7102-reset.sh @@ -70,27 +70,27 @@ check_changes () { test_expect_success 'reset --hard message' ' hex=$(git log -1 --format="%h") && - git reset --hard > .actual && - echo HEAD is now at $hex $(commit_msg) > .expected && + git reset --hard >.actual && + echo HEAD is now at $hex $(commit_msg) >.expected && test_i18ncmp .expected .actual ' test_expect_success 'reset --hard message (ISO8859-1 logoutputencoding)' ' hex=$(git log -1 --format="%h") && - git -c "i18n.logOutputEncoding=$test_encoding" reset --hard > .actual && - echo HEAD is now at $hex $(commit_msg $test_encoding) > .expected && + git -c "i18n.logOutputEncoding=$test_encoding" reset --hard >.actual && + echo HEAD is now at $hex $(commit_msg $test_encoding) >.expected && test_i18ncmp .expected .actual ' ->.diff_expect ->.cached_expect -cat >.cat_expect <<EOF -secondfile: -1st line 2nd file -2nd line 2nd file -EOF - test_expect_success 'giving a non existing revision should fail' ' + >.diff_expect && + >.cached_expect && + cat >.cat_expect <<-\EOF && + secondfile: + 1st line 2nd file + 2nd line 2nd file + EOF + test_must_fail git reset aaaaaa && test_must_fail git reset --mixed aaaaaa && test_must_fail git reset --soft aaaaaa && @@ -107,8 +107,7 @@ test_expect_success 'reset --soft with unmerged index should fail' ' git rm --cached -- un ' -test_expect_success \ - 'giving paths with options different than --mixed should fail' ' +test_expect_success 'giving paths with options different than --mixed should fail' ' test_must_fail git reset --soft -- first && test_must_fail git reset --hard -- first && test_must_fail git reset --soft HEAD^ -- first && @@ -128,8 +127,7 @@ test_expect_success 'giving unrecognized options should fail' ' check_changes $head5 ' -test_expect_success \ - 'trying to do reset --soft with pending merge should fail' ' +test_expect_success 'trying to do reset --soft with pending merge should fail' ' git branch branch1 && git branch branch2 && @@ -152,8 +150,7 @@ test_expect_success \ check_changes $head5 ' -test_expect_success \ - 'trying to do reset --soft with pending checkout merge should fail' ' +test_expect_success 'trying to do reset --soft with pending checkout merge should fail' ' git branch branch3 && git branch branch4 && @@ -175,8 +172,7 @@ test_expect_success \ check_changes $head5 ' -test_expect_success \ - 'resetting to HEAD with no changes should succeed and do nothing' ' +test_expect_success 'resetting to HEAD with no changes should succeed and do nothing' ' git reset --hard && check_changes $head5 && git reset --hard HEAD && @@ -195,39 +191,38 @@ test_expect_success \ check_changes $head5 ' ->.diff_expect -cat >.cached_expect <<EOF -diff --git a/secondfile b/secondfile -index $head5p1s..$head5s 100644 ---- a/secondfile -+++ b/secondfile -@@ -1 +1,2 @@ --2nd file -+1st line 2nd file -+2nd line 2nd file -EOF -cat >.cat_expect <<EOF -secondfile: -1st line 2nd file -2nd line 2nd file -EOF test_expect_success '--soft reset only should show changes in diff --cached' ' + >.diff_expect && + cat >.cached_expect <<-EOF && + diff --git a/secondfile b/secondfile + index $head5p1s..$head5s 100644 + --- a/secondfile + +++ b/secondfile + @@ -1 +1,2 @@ + -2nd file + +1st line 2nd file + +2nd line 2nd file + EOF + cat >.cat_expect <<-\EOF && + secondfile: + 1st line 2nd file + 2nd line 2nd file + EOF git reset --soft HEAD^ && check_changes $head5p1 && test "$(git rev-parse ORIG_HEAD)" = \ $head5 ' ->.diff_expect ->.cached_expect -cat >.cat_expect <<EOF -secondfile: -1st line 2nd file -2nd line 2nd file -3rd line 2nd file -EOF -test_expect_success \ - 'changing files and redo the last commit should succeed' ' +test_expect_success 'changing files and redo the last commit should succeed' ' + >.diff_expect && + >.cached_expect && + cat >.cat_expect <<-\EOF && + secondfile: + 1st line 2nd file + 2nd line 2nd file + 3rd line 2nd file + EOF echo "3rd line 2nd file" >>secondfile && git commit -a -C ORIG_HEAD && head4=$(git rev-parse --verify HEAD) && @@ -236,56 +231,54 @@ test_expect_success \ $head5 ' ->.diff_expect ->.cached_expect -cat >.cat_expect <<EOF -first: -1st file -2nd line 1st file -second: -2nd file -EOF -test_expect_success \ - '--hard reset should change the files and undo commits permanently' ' +test_expect_success '--hard reset should change the files and undo commits permanently' ' + >.diff_expect && + >.cached_expect && + cat >.cat_expect <<-\EOF && + first: + 1st file + 2nd line 1st file + second: + 2nd file + EOF git reset --hard HEAD~2 && check_changes $head5p2 && test "$(git rev-parse ORIG_HEAD)" = \ $head4 ' ->.diff_expect -cat >.cached_expect <<EOF -diff --git a/first b/first -deleted file mode 100644 -index $head5p2f..0000000 ---- a/first -+++ /dev/null -@@ -1,2 +0,0 @@ --1st file --2nd line 1st file -diff --git a/second b/second -deleted file mode 100644 -index $head5p1s..0000000 ---- a/second -+++ /dev/null -@@ -1 +0,0 @@ --2nd file -diff --git a/secondfile b/secondfile -new file mode 100644 -index 0000000..$head5s ---- /dev/null -+++ b/secondfile -@@ -0,0 +1,2 @@ -+1st line 2nd file -+2nd line 2nd file -EOF -cat >.cat_expect <<EOF -secondfile: -1st line 2nd file -2nd line 2nd file -EOF -test_expect_success \ - 'redoing changes adding them without commit them should succeed' ' +test_expect_success 'redoing changes adding them without commit them should succeed' ' + >.diff_expect && + cat >.cached_expect <<-EOF && + diff --git a/first b/first + deleted file mode 100644 + index $head5p2f..0000000 + --- a/first + +++ /dev/null + @@ -1,2 +0,0 @@ + -1st file + -2nd line 1st file + diff --git a/second b/second + deleted file mode 100644 + index $head5p1s..0000000 + --- a/second + +++ /dev/null + @@ -1 +0,0 @@ + -2nd file + diff --git a/secondfile b/secondfile + new file mode 100644 + index 0000000..$head5s + --- /dev/null + +++ b/secondfile + @@ -0,0 +1,2 @@ + +1st line 2nd file + +2nd line 2nd file + EOF + cat >.cat_expect <<-\EOF && + secondfile: + 1st line 2nd file + 2nd line 2nd file + EOF git rm first && git mv second secondfile && @@ -295,46 +288,45 @@ test_expect_success \ check_changes $head5p2 ' -cat >.diff_expect <<EOF -diff --git a/first b/first -deleted file mode 100644 -index $head5p2f..0000000 ---- a/first -+++ /dev/null -@@ -1,2 +0,0 @@ --1st file --2nd line 1st file -diff --git a/second b/second -deleted file mode 100644 -index $head5p1s..0000000 ---- a/second -+++ /dev/null -@@ -1 +0,0 @@ --2nd file -EOF ->.cached_expect -cat >.cat_expect <<EOF -secondfile: -1st line 2nd file -2nd line 2nd file -EOF test_expect_success '--mixed reset to HEAD should unadd the files' ' + cat >.diff_expect <<-EOF && + diff --git a/first b/first + deleted file mode 100644 + index $head5p2f..0000000 + --- a/first + +++ /dev/null + @@ -1,2 +0,0 @@ + -1st file + -2nd line 1st file + diff --git a/second b/second + deleted file mode 100644 + index $head5p1s..0000000 + --- a/second + +++ /dev/null + @@ -1 +0,0 @@ + -2nd file + EOF + >.cached_expect && + cat >.cat_expect <<-\EOF && + secondfile: + 1st line 2nd file + 2nd line 2nd file + EOF git reset && check_changes $head5p2 && test "$(git rev-parse ORIG_HEAD)" = $head5p2 ' ->.diff_expect ->.cached_expect -cat >.cat_expect <<EOF -secondfile: -1st line 2nd file -2nd line 2nd file -EOF test_expect_success 'redoing the last two commits should succeed' ' + >.diff_expect && + >.cached_expect && + cat >.cat_expect <<-\EOF && + secondfile: + 1st line 2nd file + 2nd line 2nd file + EOF git add secondfile && git reset --hard $head5p2 && - git rm first && git mv second secondfile && git commit -a -m "remove 1st and rename 2nd" && @@ -347,15 +339,15 @@ test_expect_success 'redoing the last two commits should succeed' ' check_changes $head5 ' ->.diff_expect ->.cached_expect -cat >.cat_expect <<EOF -secondfile: -1st line 2nd file -2nd line 2nd file -3rd line in branch2 -EOF test_expect_success '--hard reset to HEAD should clear a failed merge' ' + >.diff_expect && + >.cached_expect && + cat >.cat_expect <<-\EOF && + secondfile: + 1st line 2nd file + 2nd line 2nd file + 3rd line in branch2 + EOF git branch branch1 && git branch branch2 && @@ -373,15 +365,14 @@ test_expect_success '--hard reset to HEAD should clear a failed merge' ' check_changes $head3 ' ->.diff_expect ->.cached_expect -cat >.cat_expect <<EOF -secondfile: -1st line 2nd file -2nd line 2nd file -EOF -test_expect_success \ - '--hard reset to ORIG_HEAD should clear a fast-forward merge' ' +test_expect_success '--hard reset to ORIG_HEAD should clear a fast-forward merge' ' + >.diff_expect && + >.cached_expect && + cat >.cat_expect <<-\EOF && + secondfile: + 1st line 2nd file + 2nd line 2nd file + EOF git reset --hard HEAD^ && check_changes $head5 && @@ -395,25 +386,25 @@ test_expect_success \ ' test_expect_success 'test --mixed <paths>' ' - echo 1 > file1 && - echo 2 > file2 && + echo 1 >file1 && + echo 2 >file2 && git add file1 file2 && test_tick && git commit -m files && before1=$(git rev-parse --short HEAD:file1) && before2=$(git rev-parse --short HEAD:file2) && git rm file2 && - echo 3 > file3 && - echo 4 > file4 && - echo 5 > file1 && + echo 3 >file3 && + echo 4 >file4 && + echo 5 >file1 && after1=$(git rev-parse --short $(git hash-object file1)) && after4=$(git rev-parse --short $(git hash-object file4)) && git add file1 file3 file4 && git reset HEAD -- file1 file2 file3 && test_must_fail git diff --quiet && - git diff > output && + git diff >output && - cat > expect <<-EOF && + cat >expect <<-EOF && diff --git a/file1 b/file1 index $before1..$after1 100644 --- a/file1 @@ -431,9 +422,9 @@ test_expect_success 'test --mixed <paths>' ' EOF test_cmp expect output && - git diff --cached > output && + git diff --cached >output && - cat > cached_expect <<-EOF && + cat >cached_expect <<-EOF && diff --git a/file4 b/file4 new file mode 100644 index 0000000..$after4 @@ -447,7 +438,6 @@ test_expect_success 'test --mixed <paths>' ' ' test_expect_success 'test resetting the index at give paths' ' - mkdir sub && >sub/file1 && >sub/file2 && @@ -460,7 +450,6 @@ test_expect_success 'test resetting the index at give paths' ' echo "$U" && test_must_fail git diff-index --cached --exit-code "$T" && test "$T" != "$U" - ' test_expect_success 'resetting an unmodified path is a no-op' ' @@ -470,14 +459,13 @@ test_expect_success 'resetting an unmodified path is a no-op' ' git diff-index --cached --exit-code HEAD ' -cat > expect << EOF -Unstaged changes after reset: -M file2 -EOF - test_expect_success '--mixed refreshes the index' ' - echo 123 >> file2 && - git reset --mixed HEAD > output && + cat >expect <<-\EOF && + Unstaged changes after reset: + M file2 + EOF + echo 123 >>file2 && + git reset --mixed HEAD >output && test_i18ncmp expect output ' @@ -498,7 +486,6 @@ test_expect_success 'resetting specific path that is unmerged' ' ' test_expect_success 'disambiguation (1)' ' - git reset --hard && >secondfile && git add secondfile && @@ -507,11 +494,9 @@ test_expect_success 'disambiguation (1)' ' test -z "$(git diff --cached --name-only)" && test -f secondfile && test_must_be_empty secondfile - ' test_expect_success 'disambiguation (2)' ' - git reset --hard && >secondfile && git add secondfile && @@ -519,11 +504,9 @@ test_expect_success 'disambiguation (2)' ' test_must_fail git reset secondfile && test -n "$(git diff --cached --name-only -- secondfile)" && test ! -f secondfile - ' test_expect_success 'disambiguation (3)' ' - git reset --hard && >secondfile && git add secondfile && @@ -532,11 +515,9 @@ test_expect_success 'disambiguation (3)' ' test_must_fail git diff --quiet && test -z "$(git diff --cached --name-only)" && test ! -f secondfile - ' test_expect_success 'disambiguation (4)' ' - git reset --hard && >secondfile && git add secondfile && diff --git a/t/t7201-co.sh b/t/t7201-co.sh index 4d62b9b00f..b36a93056f 100755 --- a/t/t7201-co.sh +++ b/t/t7201-co.sh @@ -33,8 +33,7 @@ fill () { test_expect_success setup ' - - fill x y z > same && + fill x y z >same && fill 1 2 3 4 5 6 7 8 >one && fill a b c d e >two && git add same one two && @@ -56,14 +55,13 @@ test_expect_success setup ' git checkout -b simple master && rm -f one && - fill a c e > two && + fill a c e >two && git commit -a -m "Simple D one, M two" && git checkout master ' -test_expect_success "checkout from non-existing branch" ' - +test_expect_success 'checkout from non-existing branch' ' git checkout -b delete-me master && git update-ref -d --no-deref refs/heads/delete-me && test refs/heads/delete-me = "$(git symbolic-ref HEAD)" && @@ -71,8 +69,7 @@ test_expect_success "checkout from non-existing branch" ' test refs/heads/master = "$(git symbolic-ref HEAD)" ' -test_expect_success "checkout with dirty tree without -m" ' - +test_expect_success 'checkout with dirty tree without -m' ' fill 0 1 2 3 4 5 6 7 8 >one && if git checkout side then @@ -81,11 +78,9 @@ test_expect_success "checkout with dirty tree without -m" ' else echo "happy - failed correctly" fi - ' -test_expect_success "checkout with unrelated dirty tree without -m" ' - +test_expect_success 'checkout with unrelated dirty tree without -m' ' git checkout -f master && fill 0 1 2 3 4 5 6 7 8 >same && cp same kept && @@ -95,13 +90,12 @@ test_expect_success "checkout with unrelated dirty tree without -m" ' test_cmp messages.expect messages ' -test_expect_success "checkout -m with dirty tree" ' - +test_expect_success 'checkout -m with dirty tree' ' git checkout -f master && git clean -f && fill 0 1 2 3 4 5 6 7 8 >one && - git checkout -m side > messages && + git checkout -m side >messages && test "$(git symbolic-ref HEAD)" = "refs/heads/side" && @@ -120,8 +114,7 @@ test_expect_success "checkout -m with dirty tree" ' test_must_be_empty current.index ' -test_expect_success "checkout -m with dirty tree, renamed" ' - +test_expect_success 'checkout -m with dirty tree, renamed' ' git checkout -f master && git clean -f && fill 1 2 3 4 5 7 8 >one && @@ -139,11 +132,9 @@ test_expect_success "checkout -m with dirty tree, renamed" ' ! test -f one && git diff --cached >current && test_must_be_empty current - ' test_expect_success 'checkout -m with merge conflict' ' - git checkout -f master && git clean -f && fill 1 T 3 4 5 6 S 8 >one && @@ -166,10 +157,10 @@ test_expect_success 'checkout -m with merge conflict' ' ' test_expect_success 'format of merge conflict from checkout -m' ' + git checkout -f master && + git clean -f && - git checkout -f master && git clean -f && - - fill b d > two && + fill b d >two && git checkout -m simple && git ls-files >current && @@ -190,10 +181,11 @@ test_expect_success 'format of merge conflict from checkout -m' ' ' test_expect_success 'checkout --merge --conflict=diff3 <branch>' ' + git checkout -f master && + git reset --hard && + git clean -f && - git checkout -f master && git reset --hard && git clean -f && - - fill b d > two && + fill b d >two && git checkout --merge --conflict=diff3 simple && cat <<-EOF >expect && @@ -216,8 +208,9 @@ test_expect_success 'checkout --merge --conflict=diff3 <branch>' ' ' test_expect_success 'switch to another branch while carrying a deletion' ' - - git checkout -f master && git reset --hard && git clean -f && + git checkout -f master && + git reset --hard && + git clean -f && git rm two && test_must_fail git checkout simple 2>errs && @@ -228,10 +221,10 @@ test_expect_success 'switch to another branch while carrying a deletion' ' ' test_expect_success 'checkout to detach HEAD (with advice declined)' ' - git config advice.detachedHead false && rev=$(git rev-parse --short renamer^) && - git checkout -f renamer && git clean -f && + git checkout -f renamer && + git clean -f && git checkout renamer^ 2>messages && test_i18ngrep "HEAD is now at $rev" messages && test_line_count = 1 messages && @@ -250,7 +243,8 @@ test_expect_success 'checkout to detach HEAD (with advice declined)' ' test_expect_success 'checkout to detach HEAD' ' git config advice.detachedHead true && rev=$(git rev-parse --short renamer^) && - git checkout -f renamer && git clean -f && + git checkout -f renamer && + git clean -f && GIT_TEST_GETTEXT_POISON=false git checkout renamer^ 2>messages && grep "HEAD is now at $rev" messages && test_line_count -gt 1 messages && @@ -267,8 +261,8 @@ test_expect_success 'checkout to detach HEAD' ' ' test_expect_success 'checkout to detach HEAD with branchname^' ' - - git checkout -f master && git clean -f && + git checkout -f master && + git clean -f && git checkout renamer^ && H=$(git rev-parse --verify HEAD) && M=$(git show-ref -s --verify refs/heads/master) && @@ -283,8 +277,8 @@ test_expect_success 'checkout to detach HEAD with branchname^' ' ' test_expect_success 'checkout to detach HEAD with :/message' ' - - git checkout -f master && git clean -f && + git checkout -f master && + git clean -f && git checkout ":/Initial" && H=$(git rev-parse --verify HEAD) && M=$(git show-ref -s --verify refs/heads/master) && @@ -299,8 +293,8 @@ test_expect_success 'checkout to detach HEAD with :/message' ' ' test_expect_success 'checkout to detach HEAD with HEAD^0' ' - - git checkout -f master && git clean -f && + git checkout -f master && + git clean -f && git checkout HEAD^0 && H=$(git rev-parse --verify HEAD) && M=$(git show-ref -s --verify refs/heads/master) && @@ -315,7 +309,6 @@ test_expect_success 'checkout to detach HEAD with HEAD^0' ' ' test_expect_success 'checkout with ambiguous tag/branch names' ' - git tag both side && git branch both master && git reset --hard && @@ -327,11 +320,9 @@ test_expect_success 'checkout with ambiguous tag/branch names' ' test "z$H" = "z$M" && name=$(git symbolic-ref HEAD 2>/dev/null) && test "z$name" = zrefs/heads/both - ' test_expect_success 'checkout with ambiguous tag/branch names' ' - git reset --hard && git checkout master && @@ -351,26 +342,19 @@ test_expect_success 'checkout with ambiguous tag/branch names' ' else : happy fi - ' test_expect_success 'switch branches while in subdirectory' ' - git reset --hard && git checkout master && mkdir subs && - ( - cd subs && - git checkout side - ) && + git -C subs checkout side && ! test -f subs/one && rm -fr subs - ' test_expect_success 'checkout specific path while in subdirectory' ' - git reset --hard && git checkout side && mkdir subs && @@ -380,30 +364,26 @@ test_expect_success 'checkout specific path while in subdirectory' ' git checkout master && mkdir -p subs && - ( - cd subs && - git checkout side -- bero - ) && + git -C subs checkout side -- bero && test -f subs/bero - ' -test_expect_success \ - 'checkout w/--track sets up tracking' ' +test_expect_success 'checkout w/--track sets up tracking' ' git config branch.autosetupmerge false && git checkout master && git checkout --track -b track1 && test "$(git config branch.track1.remote)" && - test "$(git config branch.track1.merge)"' + test "$(git config branch.track1.merge)" +' -test_expect_success \ - 'checkout w/autosetupmerge=always sets up tracking' ' +test_expect_success 'checkout w/autosetupmerge=always sets up tracking' ' test_when_finished git config branch.autosetupmerge false && git config branch.autosetupmerge always && git checkout master && git checkout -b track2 && test "$(git config branch.track2.remote)" && - test "$(git config branch.track2.merge)"' + test "$(git config branch.track2.merge)" +' test_expect_success 'checkout w/--track from non-branch HEAD fails' ' git checkout master^0 && @@ -435,8 +415,7 @@ test_expect_success 'detach a symbolic link HEAD' ' test "z$(git rev-parse --verify refs/heads/master)" = "z$here" ' -test_expect_success \ - 'checkout with --track fakes a sensible -b <name>' ' +test_expect_success 'checkout with --track fakes a sensible -b <name>' ' git config remote.origin.fetch "+refs/heads/*:refs/remotes/origin/*" && git update-ref refs/remotes/origin/koala/bear renamer && @@ -457,9 +436,9 @@ test_expect_success \ test "$(git rev-parse HEAD)" = "$(git rev-parse renamer)" ' -test_expect_success \ - 'checkout with --track, but without -b, fails with too short tracked name' ' - test_must_fail git checkout --track renamer' +test_expect_success 'checkout with --track, but without -b, fails with too short tracked name' ' + test_must_fail git checkout --track renamer +' setup_conflicting_index () { rm -f .git/index && @@ -609,7 +588,6 @@ test_expect_success 'failing checkout -b should not break working tree' ' test $(git symbolic-ref HEAD) = refs/heads/master && git diff --exit-code && git diff --cached --exit-code - ' test_expect_success 'switch out of non-branch' ' |