Skip to content

Commit 08830ac

Browse files
calebdwgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Caleb White <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 717af91 commit 08830ac

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

t/t2401-worktree-prune.sh

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,4 +120,23 @@ test_expect_success 'prune duplicate (main/linked)' '
120120
! test -d .git/worktrees/wt
121121
'
122122

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+
123142
test_done

0 commit comments

Comments
 (0)