3 test_description
='checkout switching away from an invalid branch'
5 GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
=main
6 export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
8 TEST_PASSES_SANITIZE_LEAK
=true
11 test_expect_success
'setup' '
17 test_expect_success
'checkout should not start branch from a tree' '
18 test_must_fail git checkout -b newbranch main^{tree}
21 test_expect_success REFFILES
'checkout main from invalid HEAD' '
22 echo $ZERO_OID >.git/HEAD &&
26 test_expect_success REFFILES
'checkout notices failure to lock HEAD' '
27 test_when_finished "rm -f .git/HEAD.lock" &&
29 test_must_fail git checkout -b other
32 test_expect_success
'create ref directory/file conflict scenario' '
33 git update-ref refs/heads/outer/inner main &&
35 git symbolic-ref HEAD refs/heads/outer
39 test_expect_success
'checkout away from d/f HEAD (unpacked, to branch)' '
44 test_expect_success
'checkout away from d/f HEAD (unpacked, to detached)' '
46 git checkout --detach main
49 test_expect_success
'pack refs' '
50 git pack-refs --all --prune
53 test_expect_success
'checkout away from d/f HEAD (packed, to branch)' '
58 test_expect_success
'checkout away from d/f HEAD (packed, to detached)' '
60 git checkout --detach main