3 test_description
='checkout from unborn branch'
4 GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
=main
5 export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
7 TEST_PASSES_SANITIZE_LEAK
=true
10 test_expect_success
'setup' '
18 git fetch parent main:origin
21 test_expect_success
'checkout from unborn preserves untracked files' '
22 echo precious >expect &&
23 echo precious >file &&
24 test_must_fail git checkout -b new origin &&
28 test_expect_success
'checkout from unborn preserves index contents' '
29 echo precious >expect &&
30 echo precious >file &&
32 test_must_fail git checkout -b new origin &&
33 test_cmp expect file &&
34 git show :file >file &&
38 test_expect_success
'checkout from unborn merges identical index contents' '
41 git checkout -b new origin
44 test_expect_success
'checking out another branch from unborn state' '
45 git checkout --orphan newroot &&
46 git checkout -b anothername &&
47 test_must_fail git show-ref --verify refs/heads/newroot &&
48 git symbolic-ref HEAD >actual &&
49 echo refs/heads/anothername >expect &&
50 test_cmp expect actual
53 test_expect_success
'checking out in a newly created repo' '
54 test_create_repo empty &&
57 git symbolic-ref HEAD >expect &&
58 test_must_fail git checkout &&
59 git symbolic-ref HEAD >actual &&
60 test_cmp expect actual