worktree: add test for path handling in linked worktrees

A failure scenario reported in an earlier patch series[1] that several `git worktree` subcommands failed or misbehaved when invoked from within linked worktrees that used relative paths. This adds a test that executes a `worktree prune` command inside both an internally and an externally linked worktree and asserts that the other worktree was not pruned. [1]: https://lore.kernel.org/git/CAPig+cQXFy=xPVpoSq6Wq0pxMRCjS=WbkgdO+3LySPX=q0nPCw@mail.gmail.com/ Reported-by: Eric Sunshine <sunshine@sunshineco.com> Signed-off-by: Caleb White <cdwhite3@pm.me> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Caleb White committed Oct 7, 2024 at 22:12 UTC 08830ac00f2e6173d5248744bd6f0b785189dffe
1 file changed +19
t/t2401-worktree-prune.sh
+19
@@ -120,4 +120,23 @@ test_expect_success 'prune duplicate (main/linked)' '
120 ! test -d .git/worktrees/wt
121 '
122
123 +test_expect_success 'not prune proper worktrees when run inside linked worktree' '
124 + test_when_finished rm -rf repo wt_ext &&
125 + git init repo &&
126 + (
127 + cd repo &&
128 + echo content >file &&
129 + git add file &&
130 + git commit -m msg &&
131 + git worktree add ../wt_ext &&
132 + git worktree add wt_int &&
133 + cd wt_int &&
134 + git worktree prune -v >out &&
135 + test_must_be_empty out &&
136 + cd ../../wt_ext &&
137 + git worktree prune -v >out &&
138 + test_must_be_empty out
139 + )
140 +'
141 +
142 test_done