]> git.ipfire.org Git - thirdparty/git.git/commitdiff
t2402: ensure locked worktree is properly cleaned up
authorRafael Silva <rafaeloliveira.cs@gmail.com>
Wed, 27 Jan 2021 08:03:07 +0000 (09:03 +0100)
committerJunio C Hamano <gitster@pobox.com>
Sat, 30 Jan 2021 17:57:24 +0000 (09:57 -0800)
c57b3367be (worktree: teach `list` to annotate locked worktree,
2020-10-11) introduced a new test to ensure locked worktrees are listed
with "locked" annotation. However, the test does not clean up after
itself as "git worktree prune" is not going to remove the locked worktree
in the first place. This not only leaves the test in an unclean state it
also potentially breaks following tests that rely on the
"git worktree list" output.

Let's fix that by unlocking the worktree before the "prune" command.

Helped-by: Eric Sunshine <sunshine@sunshineco.com>
Signed-off-by: Rafael Silva <rafaeloliveira.cs@gmail.com>
Reviewed-by: Eric Sunshine <sunshine@sunshineco.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
t/t2402-worktree-list.sh

index 795ddca2e438f4c83df373bfe94195de60fd90bd..1866ea09f6e3cfde6b2b57cf134007257b1a6063 100755 (executable)
@@ -66,6 +66,7 @@ test_expect_success '"list" all worktrees with locked annotation' '
        git worktree add --detach locked master &&
        git worktree add --detach unlocked master &&
        git worktree lock locked &&
+       test_when_finished "git worktree unlock locked" &&
        git worktree list >out &&
        grep "/locked  *[0-9a-f].* locked$" out &&
        ! grep "/unlocked  *[0-9a-f].* locked$" out