3 test_description
='checkout from unborn branch'
4 GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
=main
5 export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
9 test_expect_success
'setup' '
17 git fetch parent main:origin
20 test_expect_success
'checkout from unborn preserves untracked files' '
21 echo precious >expect &&
22 echo precious >file &&
23 test_must_fail git checkout -b new origin &&
27 test_expect_success
'checkout from unborn preserves index contents' '
28 echo precious >expect &&
29 echo precious >file &&
31 test_must_fail git checkout -b new origin &&
32 test_cmp expect file &&
33 git show :file >file &&
37 test_expect_success
'checkout from unborn merges identical index contents' '
40 git checkout -b new origin
43 test_expect_success
'checking out another branch from unborn state' '
44 git checkout --orphan newroot &&
45 git checkout -b anothername &&
46 test_must_fail git show-ref --verify refs/heads/newroot &&
47 git symbolic-ref HEAD >actual &&
48 echo refs/heads/anothername >expect &&
49 test_cmp expect actual
52 test_expect_success
'checking out in a newly created repo' '
53 test_create_repo empty &&
56 git symbolic-ref HEAD >expect &&
57 test_must_fail git checkout &&
58 git symbolic-ref HEAD >actual &&
59 test_cmp expect actual