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' '
19 git fetch parent main:origin
22 test_expect_success
'checkout from unborn preserves untracked files' '
23 echo precious >expect &&
24 echo precious >file &&
25 test_must_fail git checkout -b new origin &&
29 test_expect_success
'checkout from unborn preserves index contents' '
30 echo precious >expect &&
31 echo precious >file &&
33 test_must_fail git checkout -b new origin &&
34 test_cmp expect file &&
35 git show :file >file &&
39 test_expect_success
'checkout from unborn merges identical index contents' '
42 git checkout -b new origin
45 test_expect_success
'checking out another branch from unborn state' '
46 git checkout --orphan newroot &&
47 git checkout -b anothername &&
48 test_must_fail git show-ref --verify refs/heads/newroot &&
49 git symbolic-ref HEAD >actual &&
50 echo refs/heads/anothername >expect &&
51 test_cmp expect actual
54 test_expect_success
'checking out in a newly created repo' '
55 test_create_repo empty &&
58 git symbolic-ref HEAD >expect &&
59 test_must_fail git checkout &&
60 git symbolic-ref HEAD >actual &&
61 test_cmp expect actual