tests: worktree: retrofit "checkout --to" tests for "worktree add"
With the introduction of "git worktree add", "git checkout --to" is slated for removal. Therefore, retrofit linked worktree creation tests to use "git worktree add" instead. (The test to check exclusivity of "checkout --to" and "checkout <paths>" is dropped altogether since it becomes meaningless with retirement of "checkout --to".) Signed-off-by: Eric Sunshine <sunshine@sunshineco.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Eric Sunshine committed
Jul 6, 2015 at 13:30 UTC
f194b1ef6ee81788a45053fa6f7409233fc54276
3 files changed
+25
-29
t/t2025-worktree-add.sh
renamed
+22
-26
@@ -1,6 +1,6 @@
1
#!/bin/sh
2
3
-test_description='test git checkout --to'
3
+test_description='test git worktree add'
4
5
. ./test-lib.sh
6
@@ -8,22 +8,18 @@ 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' '
11
+test_expect_success '"add" an existing worktree' '
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
14
'
15
20
-test_expect_success 'checkout --to an existing empty worktree' '
16
+test_expect_success '"add" an existing empty worktree' '
17
mkdir existing_empty &&
22
- git checkout --detach --to existing_empty master
18
+ git worktree add --detach existing_empty master
19
'
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 &&
23
! test -d zere &&
24
! test -d .git/worktrees/zere
25
'
@@ -36,9 +32,9 @@ test_expect_success 'checking out paths not complaining about linked checkouts'
32
)
33
'
34
39
-test_expect_success 'checkout --to a new worktree' '
35
+test_expect_success '"add" worktree' '
36
git rev-parse HEAD >expect &&
41
- git checkout --detach --to here master &&
37
+ git worktree add --detach here master &&
38
(
39
cd here &&
40
test_cmp ../init.t init.t &&
@@ -49,27 +45,27 @@ test_expect_success 'checkout --to a new worktree' '
45
)
46
'
47
52
-test_expect_success 'checkout --to a new worktree from a subdir' '
48
+test_expect_success '"add" worktree from a subdir' '
49
(
50
mkdir sub &&
51
cd sub &&
56
- git checkout --detach --to here master &&
52
+ git worktree add --detach here master &&
53
cd here &&
54
test_cmp ../../init.t init.t
55
)
56
'
57
62
-test_expect_success 'checkout --to from a linked checkout' '
58
+test_expect_success '"add" from a linked checkout' '
59
(
60
cd here &&
65
- git checkout --detach --to nested-here master &&
61
+ git worktree add --detach nested-here master &&
62
cd nested-here &&
63
git fsck
64
)
65
'
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 &&
69
(
70
cd there &&
71
test_cmp ../init.t init.t &&
@@ -90,7 +86,7 @@ test_expect_success 'die the same branch is already checked out' '
86
test_expect_success 'not die the same branch is already checked out' '
87
(
88
cd here &&
93
- git checkout --ignore-other-worktrees --to anothernewmaster newmaster
89
+ git worktree add --force anothernewmaster newmaster
90
)
91
'
92
@@ -101,15 +97,15 @@ test_expect_success 'not die on re-checking out current branch' '
97
)
98
'
99
104
-test_expect_success 'checkout --to from a bare repo' '
100
+test_expect_success '"add" from a bare repo' '
101
(
102
git clone --bare . bare &&
103
cd bare &&
108
- git checkout --to ../there2 -b bare-master master
104
+ git worktree add -b bare-master ../there2 master
105
)
106
'
107
112
-test_expect_success 'checkout from a bare repo without --to' '
108
+test_expect_success 'checkout from a bare repo without "add"' '
109
(
110
cd bare &&
111
test_must_fail git checkout master
@@ -129,17 +125,17 @@ test_expect_success 'checkout with grafts' '
125
EOF
126
git log --format=%s -2 >actual &&
127
test_cmp expected actual &&
132
- git checkout --detach --to grafted master &&
128
+ git worktree add --detach grafted master &&
129
git --git-dir=grafted/.git log --format=%s -2 >actual &&
130
test_cmp expected actual
131
'
132
137
-test_expect_success 'checkout --to from relative HEAD' '
133
+test_expect_success '"add" from relative HEAD' '
134
test_commit a &&
135
test_commit b &&
136
test_commit c &&
137
git rev-parse HEAD~1 >expected &&
142
- git checkout --to relhead HEAD~1 &&
138
+ git worktree add relhead HEAD~1 &&
139
git -C relhead rev-parse HEAD >actual &&
140
test_cmp expected actual
141
'
t/t2026-prune-linked-checkouts.sh
+1
-1
@@ -88,7 +88,7 @@ test_expect_success 'not prune recent checkouts' '
88
89
test_expect_success 'not prune proper checkouts' '
90
test_when_finished rm -r .git/worktrees &&
91
- git checkout "--to=$PWD/nop" --detach master &&
91
+ git worktree add --detach "$PWD/nop" master &&
92
git worktree prune &&
93
test -d .git/worktrees/nop
94
'
t/t7410-submodule-checkout-to.sh
+2
-2
@@ -33,7 +33,7 @@ rev1_hash_sub=$(git --git-dir=origin/sub/.git show --pretty=format:%h -q "HEAD~1
33
test_expect_success 'checkout main' \
34
'mkdir default_checkout &&
35
(cd clone/main &&
36
- git checkout --to "$base_path/default_checkout/main" "$rev1_hash_main")'
36
+ git worktree add "$base_path/default_checkout/main" "$rev1_hash_main")'
37
38
test_expect_failure 'can see submodule diffs just after checkout' \
39
'(cd default_checkout/main && git diff --submodule master"^!" | grep "file1 updated")'
@@ -41,7 +41,7 @@ test_expect_failure 'can see submodule diffs just after checkout' \
41
test_expect_success 'checkout main and initialize independed clones' \
42
'mkdir fully_cloned_submodule &&
43
(cd clone/main &&
44
- git checkout --to "$base_path/fully_cloned_submodule/main" "$rev1_hash_main") &&
44
+ git worktree add "$base_path/fully_cloned_submodule/main" "$rev1_hash_main") &&
45
(cd fully_cloned_submodule/main && git submodule update)'
46
47
test_expect_success 'can see submodule diffs after independed cloning' \