]>
Commit | Line | Data |
---|---|---|
cc580af8 JK |
1 | #!/bin/sh |
2 | ||
abe19980 | 3 | test_description='checkout from unborn branch' |
334afbc7 JS |
4 | GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=master |
5 | export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME | |
6 | ||
cc580af8 JK |
7 | . ./test-lib.sh |
8 | ||
9 | test_expect_success 'setup' ' | |
10 | mkdir parent && | |
11 | (cd parent && | |
12 | git init && | |
13 | echo content >file && | |
14 | git add file && | |
15 | git commit -m base | |
16 | ) && | |
17 | git fetch parent master:origin | |
18 | ' | |
19 | ||
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 && | |
24 | test_cmp expect file | |
25 | ' | |
26 | ||
27 | test_expect_success 'checkout from unborn preserves index contents' ' | |
28 | echo precious >expect && | |
29 | echo precious >file && | |
30 | git add file && | |
31 | test_must_fail git checkout -b new origin && | |
32 | test_cmp expect file && | |
33 | git show :file >file && | |
34 | test_cmp expect file | |
35 | ' | |
36 | ||
37 | test_expect_success 'checkout from unborn merges identical index contents' ' | |
38 | echo content >file && | |
39 | git add file && | |
40 | git checkout -b new origin | |
41 | ' | |
42 | ||
abe19980 JH |
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 | |
50 | ' | |
51 | ||
8338f771 EFL |
52 | test_expect_success 'checking out in a newly created repo' ' |
53 | test_create_repo empty && | |
54 | ( | |
55 | cd empty && | |
56 | git symbolic-ref HEAD >expect && | |
57 | test_must_fail git checkout && | |
58 | git symbolic-ref HEAD >actual && | |
59 | test_cmp expect actual | |
60 | ) | |
61 | ' | |
62 | ||
cc580af8 | 63 | test_done |