3 test_description='checkout from unborn branch'
6 test_expect_success 'setup' '
14 git fetch parent master:origin
17 test_expect_success 'checkout from unborn preserves untracked files' '
18 echo precious >expect &&
19 echo precious >file &&
20 test_must_fail git checkout -b new origin &&
24 test_expect_success 'checkout from unborn preserves index contents' '
25 echo precious >expect &&
26 echo precious >file &&
28 test_must_fail git checkout -b new origin &&
29 test_cmp expect file &&
30 git show :file >file &&
34 test_expect_success 'checkout from unborn merges identical index contents' '
37 git checkout -b new origin
40 test_expect_success 'checking out another branch from unborn state' '
41 git checkout --orphan newroot &&
42 git checkout -b anothername &&
43 test_must_fail git show-ref --verify refs/heads/newroot &&
44 git symbolic-ref HEAD >actual &&
45 echo refs/heads/anothername >expect &&
46 test_cmp expect actual
49 test_expect_success 'checking out in a newly created repo' '
50 test_create_repo empty &&
53 git symbolic-ref HEAD >expect &&
54 test_must_fail git checkout &&
55 git symbolic-ref HEAD >actual &&
56 test_cmp expect actual