3 test_description='checkout can switch to last branch'
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