]>
Commit | Line | Data |
---|---|---|
529fef20 NTND |
1 | #!/bin/sh |
2 | ||
3 | test_description='test git checkout --to' | |
4 | ||
5 | . ./test-lib.sh | |
6 | ||
7 | test_expect_success 'setup' ' | |
8 | test_commit init | |
9 | ' | |
10 | ||
11 | test_expect_success 'checkout --to not updating paths' ' | |
12 | test_must_fail git checkout --to -- init.t | |
13 | ' | |
14 | ||
15 | test_expect_success 'checkout --to an existing worktree' ' | |
16 | mkdir existing && | |
17 | test_must_fail git checkout --detach --to existing master | |
18 | ' | |
19 | ||
20 | test_expect_success 'checkout --to a new worktree' ' | |
5883034c NTND |
21 | git rev-parse HEAD >expect && |
22 | git checkout --detach --to here master && | |
529fef20 NTND |
23 | ( |
24 | cd here && | |
25 | test_cmp ../init.t init.t && | |
5883034c NTND |
26 | test_must_fail git symbolic-ref HEAD && |
27 | git rev-parse HEAD >actual && | |
28 | test_cmp ../expect actual && | |
529fef20 NTND |
29 | git fsck |
30 | ) | |
31 | ' | |
32 | ||
33 | test_expect_success 'checkout --to a new worktree from a subdir' ' | |
34 | ( | |
35 | mkdir sub && | |
36 | cd sub && | |
37 | git checkout --detach --to here master && | |
38 | cd here && | |
39 | test_cmp ../../init.t init.t | |
40 | ) | |
41 | ' | |
42 | ||
43 | test_expect_success 'checkout --to from a linked checkout' ' | |
44 | ( | |
45 | cd here && | |
5883034c | 46 | git checkout --detach --to nested-here master && |
529fef20 NTND |
47 | cd nested-here && |
48 | git fsck | |
49 | ) | |
50 | ' | |
51 | ||
52 | test_expect_success 'checkout --to a new worktree creating new branch' ' | |
53 | git checkout --to there -b newmaster master && | |
54 | ( | |
55 | cd there && | |
56 | test_cmp ../init.t init.t && | |
57 | git symbolic-ref HEAD >actual && | |
58 | echo refs/heads/newmaster >expect && | |
59 | test_cmp expect actual && | |
60 | git fsck | |
61 | ) | |
62 | ' | |
63 | ||
5883034c NTND |
64 | test_expect_success 'die the same branch is already checked out' ' |
65 | ( | |
66 | cd here && | |
67 | test_must_fail git checkout newmaster | |
68 | ) | |
69 | ' | |
70 | ||
71 | test_expect_success 'not die on re-checking out current branch' ' | |
72 | ( | |
73 | cd there && | |
74 | git checkout newmaster | |
75 | ) | |
76 | ' | |
77 | ||
529fef20 | 78 | test_done |