3 test_description
='checkout can switch to last branch and merge base'
7 test_expect_success
'setup' '
10 git commit -m initial &&
12 echo "hello again" >>world &&
17 test_expect_success
'"checkout -" does not work initially' '
18 test_must_fail git checkout -
21 test_expect_success
'first branch switch' '
25 test_expect_success
'"checkout -" switches back' '
27 test "z$(git symbolic-ref HEAD)" = "zrefs/heads/master"
30 test_expect_success
'"checkout -" switches forth' '
32 test "z$(git symbolic-ref HEAD)" = "zrefs/heads/other"
35 test_expect_success
'detach HEAD' '
36 git checkout $(git rev-parse HEAD)
39 test_expect_success
'"checkout -" attaches again' '
41 test "z$(git symbolic-ref HEAD)" = "zrefs/heads/other"
44 test_expect_success
'"checkout -" detaches again' '
46 test "z$(git rev-parse HEAD)" = "z$(git rev-parse other)" &&
47 test_must_fail git symbolic-ref HEAD
50 test_expect_success
'more switches' '
51 for i in 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1
53 git checkout -b branch$i
58 for i
in 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1
64 test_expect_success
'switch to the last' '
67 test "z$(git symbolic-ref HEAD)" = "zrefs/heads/branch2"
70 test_expect_success
'switch to second from the last' '
73 test "z$(git symbolic-ref HEAD)" = "zrefs/heads/branch3"
76 test_expect_success
'switch to third from the last' '
79 test "z$(git symbolic-ref HEAD)" = "zrefs/heads/branch4"
82 test_expect_success
'switch to fourth from the last' '
85 test "z$(git symbolic-ref HEAD)" = "zrefs/heads/branch5"
88 test_expect_success
'switch to twelfth from the last' '
90 git checkout @{-12} &&
91 test "z$(git symbolic-ref HEAD)" = "zrefs/heads/branch13"
94 test_expect_success
'merge base test setup' '
95 git checkout -b another other &&
96 echo "hello again" >>world &&
101 test_expect_success
'another...master' '
102 git checkout another &&
103 git checkout another...master &&
104 test "z$(git rev-parse --verify HEAD)" = "z$(git rev-parse --verify master^)"
107 test_expect_success
'...master' '
108 git checkout another &&
109 git checkout ...master &&
110 test "z$(git rev-parse --verify HEAD)" = "z$(git rev-parse --verify master^)"
113 test_expect_success
'master...' '
114 git checkout another &&
115 git checkout master... &&
116 test "z$(git rev-parse --verify HEAD)" = "z$(git rev-parse --verify master^)"