3 test_description
='checkout into detached HEAD state'
7 test_must_fail git symbolic-ref
-q HEAD
>/dev
/null
10 check_not_detached
() {
11 git symbolic-ref
-q HEAD
>/dev
/null
15 git checkout master
&&
19 test_expect_success
'setup' '
26 test_expect_success
'checkout branch does not detach' '
28 git checkout branch &&
32 test_expect_success
'checkout tag detaches' '
38 test_expect_success
'checkout branch by full name detaches' '
40 git checkout refs/heads/branch &&
44 test_expect_success
'checkout non-ref detaches' '
46 git checkout branch^ &&
50 test_expect_success
'checkout ref^0 detaches' '
52 git checkout branch^0 &&
56 test_expect_success
'checkout --detach detaches' '
58 git checkout --detach branch &&
62 test_expect_success
'checkout --detach without branch name' '
64 git checkout --detach &&
68 test_expect_success
'checkout --detach errors out for non-commit' '
70 test_must_fail git checkout --detach one^{tree} &&
74 test_expect_success
'checkout --detach errors out for extra argument' '
76 git checkout master &&
77 test_must_fail git checkout --detach tag one.t &&
81 test_expect_success
'checkout --detached and -b are incompatible' '
83 test_must_fail git checkout --detach -b newbranch tag &&
87 test_expect_success
'checkout --detach moves HEAD' '
90 git checkout --detach two &&
91 git diff --exit-code HEAD &&
92 git diff --exit-code two