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 <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Patrick Steinhardt committed
Nov 2, 2023 at 09:46 UTC
c603138e3d5bae3991fcf2ba98f09b0ea3beb056
1 file changed
+4
-4
t/t1450-fsck.sh
+4
-4
@@ -141,7 +141,7 @@ test_expect_success 'HEAD link pointing at a funny place' '
141
142
test_expect_success 'HEAD link pointing at a funny object (from different wt)' '
143
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" &&
145
git worktree add wt &&
146
echo $ZERO_OID >.git/HEAD &&
147
# avoid corrupt/broken HEAD from interfering with repo discovery
@@ -150,7 +150,7 @@ test_expect_success 'HEAD link pointing at a funny object (from different wt)' '
150
'
151
152
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" &&
154
git worktree add other &&
155
echo $ZERO_OID >.git/worktrees/other/HEAD &&
156
test_must_fail git fsck 2>out &&
@@ -158,7 +158,7 @@ test_expect_success 'other worktree HEAD link pointing at a funny object' '
158
'
159
160
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" &&
162
git worktree add other &&
163
object_id=$(echo "Contents missing from repo" | git hash-object --stdin) &&
164
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' '
167
'
168
169
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" &&
171
git worktree add other &&
172
git -C other symbolic-ref HEAD refs/funny/place &&
173
test_must_fail git fsck 2>out &&