1
1
#! /bin/sh
2
2
3
- test_description=' test git checkout --to '
3
+ test_description=' test git worktree add '
4
4
5
5
. ./test-lib.sh
6
6
7
7
test_expect_success ' setup' '
8
8
test_commit init
9
9
'
10
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' '
11
+ test_expect_success ' "add" an existing worktree' '
16
12
mkdir -p existing/subtree &&
17
- test_must_fail git checkout --detach --to existing master
13
+ test_must_fail git worktree add --detach existing master
18
14
'
19
15
20
- test_expect_success ' checkout --to an existing empty worktree' '
16
+ test_expect_success ' "add" an existing empty worktree' '
21
17
mkdir existing_empty &&
22
- git checkout --detach --to existing_empty master
18
+ git worktree add --detach existing_empty master
23
19
'
24
20
25
- test_expect_success ' checkout --to refuses to checkout locked branch' '
26
- test_must_fail git checkout --to zere master &&
21
+ test_expect_success ' "add" refuses to checkout locked branch' '
22
+ test_must_fail git worktree add zere master &&
27
23
! test -d zere &&
28
24
! test -d .git/worktrees/zere
29
25
'
@@ -36,9 +32,9 @@ test_expect_success 'checking out paths not complaining about linked checkouts'
36
32
)
37
33
'
38
34
39
- test_expect_success ' checkout --to a new worktree' '
35
+ test_expect_success ' "add" worktree' '
40
36
git rev-parse HEAD >expect &&
41
- git checkout --detach --to here master &&
37
+ git worktree add --detach here master &&
42
38
(
43
39
cd here &&
44
40
test_cmp ../init.t init.t &&
@@ -49,27 +45,27 @@ test_expect_success 'checkout --to a new worktree' '
49
45
)
50
46
'
51
47
52
- test_expect_success ' checkout --to a new worktree from a subdir' '
48
+ test_expect_success ' "add" worktree from a subdir' '
53
49
(
54
50
mkdir sub &&
55
51
cd sub &&
56
- git checkout --detach --to here master &&
52
+ git worktree add --detach here master &&
57
53
cd here &&
58
54
test_cmp ../../init.t init.t
59
55
)
60
56
'
61
57
62
- test_expect_success ' checkout --to from a linked checkout' '
58
+ test_expect_success ' "add" from a linked checkout' '
63
59
(
64
60
cd here &&
65
- git checkout --detach --to nested-here master &&
61
+ git worktree add --detach nested-here master &&
66
62
cd nested-here &&
67
63
git fsck
68
64
)
69
65
'
70
66
71
- test_expect_success ' checkout --to a new worktree creating new branch' '
72
- git checkout --to there -b newmaster master &&
67
+ test_expect_success ' "add" worktree creating new branch' '
68
+ git worktree add -b newmaster there master &&
73
69
(
74
70
cd there &&
75
71
test_cmp ../init.t init.t &&
@@ -90,7 +86,7 @@ test_expect_success 'die the same branch is already checked out' '
90
86
test_expect_success ' not die the same branch is already checked out' '
91
87
(
92
88
cd here &&
93
- git checkout --ignore-other-worktrees --to anothernewmaster newmaster
89
+ git worktree add --force anothernewmaster newmaster
94
90
)
95
91
'
96
92
@@ -101,15 +97,15 @@ test_expect_success 'not die on re-checking out current branch' '
101
97
)
102
98
'
103
99
104
- test_expect_success ' checkout --to from a bare repo' '
100
+ test_expect_success ' "add" from a bare repo' '
105
101
(
106
102
git clone --bare . bare &&
107
103
cd bare &&
108
- git checkout --to ../there2 -b bare-master master
104
+ git worktree add -b bare-master ../there2 master
109
105
)
110
106
'
111
107
112
- test_expect_success ' checkout from a bare repo without --to ' '
108
+ test_expect_success ' checkout from a bare repo without "add" ' '
113
109
(
114
110
cd bare &&
115
111
test_must_fail git checkout master
@@ -129,17 +125,17 @@ test_expect_success 'checkout with grafts' '
129
125
EOF
130
126
git log --format=%s -2 >actual &&
131
127
test_cmp expected actual &&
132
- git checkout --detach --to grafted master &&
128
+ git worktree add --detach grafted master &&
133
129
git --git-dir=grafted/.git log --format=%s -2 >actual &&
134
130
test_cmp expected actual
135
131
'
136
132
137
- test_expect_success ' checkout --to from relative HEAD' '
133
+ test_expect_success ' "add" from relative HEAD' '
138
134
test_commit a &&
139
135
test_commit b &&
140
136
test_commit c &&
141
137
git rev-parse HEAD~1 >expected &&
142
- git checkout --to relhead HEAD~1 &&
138
+ git worktree add relhead HEAD~1 &&
143
139
git -C relhead rev-parse HEAD >actual &&
144
140
test_cmp expected actual
145
141
'
0 commit comments