Skip to content

Commit c603138

Browse files
pks-tgitster
authored andcommitted
t1450: convert tests to remove worktrees via git-worktree(1)
Some of our tests in t1450 create worktrees and then corrupt them. As it is impossible to delete such worktrees via a normal call to `git worktree remove`, we instead opt to remove them manually by calling rm(1) instead. This is ultimately unnecessary though as we can use the `-f` switch to remove the worktree. Let's convert the tests to do so such that we don't have to reach into internal implementation details of worktrees. Signed-off-by: Patrick Steinhardt <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 668e31c commit c603138

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

t/t1450-fsck.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ test_expect_success 'HEAD link pointing at a funny place' '
141141

142142
test_expect_success 'HEAD link pointing at a funny object (from different wt)' '
143143
test_when_finished "git update-ref HEAD $orig_head" &&
144-
test_when_finished "rm -rf .git/worktrees wt" &&
144+
test_when_finished "git worktree remove -f wt" &&
145145
git worktree add wt &&
146146
echo $ZERO_OID >.git/HEAD &&
147147
# avoid corrupt/broken HEAD from interfering with repo discovery
@@ -150,15 +150,15 @@ test_expect_success 'HEAD link pointing at a funny object (from different wt)' '
150150
'
151151

152152
test_expect_success 'other worktree HEAD link pointing at a funny object' '
153-
test_when_finished "rm -rf .git/worktrees other" &&
153+
test_when_finished "git worktree remove -f other" &&
154154
git worktree add other &&
155155
echo $ZERO_OID >.git/worktrees/other/HEAD &&
156156
test_must_fail git fsck 2>out &&
157157
test_i18ngrep "worktrees/other/HEAD: detached HEAD points" out
158158
'
159159

160160
test_expect_success 'other worktree HEAD link pointing at missing object' '
161-
test_when_finished "rm -rf .git/worktrees other" &&
161+
test_when_finished "git worktree remove -f other" &&
162162
git worktree add other &&
163163
object_id=$(echo "Contents missing from repo" | git hash-object --stdin) &&
164164
test-tool -C other ref-store main update-ref msg HEAD $object_id "" REF_NO_DEREF,REF_SKIP_OID_VERIFICATION &&
@@ -167,7 +167,7 @@ test_expect_success 'other worktree HEAD link pointing at missing object' '
167167
'
168168

169169
test_expect_success 'other worktree HEAD link pointing at a funny place' '
170-
test_when_finished "rm -rf .git/worktrees other" &&
170+
test_when_finished "git worktree remove -f other" &&
171171
git worktree add other &&
172172
git -C other symbolic-ref HEAD refs/funny/place &&
173173
test_must_fail git fsck 2>out &&

0 commit comments

Comments
 (0)