3 test_description
='checkout switching away from an invalid branch'
7 test_expect_success
'setup' '
13 test_expect_success
'checkout should not start branch from a tree' '
14 test_must_fail git checkout -b newbranch master^{tree}
17 test_expect_success
'checkout master from invalid HEAD' '
18 echo $ZERO_OID >.git/HEAD &&
19 git checkout master --
22 test_expect_success
'checkout notices failure to lock HEAD' '
23 test_when_finished "rm -f .git/HEAD.lock" &&
25 test_must_fail git checkout -b other
28 test_expect_success
'create ref directory/file conflict scenario' '
29 git update-ref refs/heads/outer/inner master &&
31 # do not rely on symbolic-ref to get a known state,
32 # as it may use the same code we are testing
34 echo "ref: refs/heads/outer" >.git/HEAD
38 test_expect_success
'checkout away from d/f HEAD (unpacked, to branch)' '
43 test_expect_success
'checkout away from d/f HEAD (unpacked, to detached)' '
45 git checkout --detach master
48 test_expect_success
'pack refs' '
49 git pack-refs --all --prune
52 test_expect_success
'checkout away from d/f HEAD (packed, to branch)' '
57 test_expect_success
'checkout away from d/f HEAD (packed, to detached)' '
59 git checkout --detach master