Thread (40 messages) 40 messages, 4 authors, 2023-11-02

Re: [PATCH v2 5/9] t1450: convert tests to remove worktrees via git-worktree(1)

From: Eric Sunshine <hidden>
Date: 2023-10-27 02:42:33

On Tue, Oct 24, 2023 at 10:05 AM Patrick Steinhardt [off-list ref] wrote:
quoted hunk ↗ jump to hunk
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 <redacted>
---
diff --git a/t/t1450-fsck.sh b/t/t1450-fsck.sh
@@ -141,7 +141,7 @@ test_expect_success 'HEAD link pointing at a funny place' '
 test_expect_success 'HEAD link pointing at a funny object (from different wt)' '
        test_when_finished "git update-ref HEAD $orig_head" &&
-       test_when_finished "rm -rf .git/worktrees wt" &&
+       test_when_finished "git worktree remove -f wt" &&
        git worktree add wt &&
        echo $ZERO_OID >.git/HEAD &&
Technically, this is a change of behavior since the original code
removed the entire .git/worktrees directory, which deleted
administrative metainformation for _all_ worktrees, whereas the new
code only deletes administrative metadata for the mentioned worktree.
However, since there are no other existing worktrees at this point in
any of these tests, the result is functionally the same, so the change
of behavior is immaterial. Moreover, the revised code has a smaller
blast-radius, which may be a desirable property since there has been
some movement toward making tests more self-contained so that they can
be run individually more easily.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help