* [PATCH] t2401: fix misfiring substitution when path contains w2
@ 2026-11-11 7:55 Anders Kaseorg
2026-11-11 16:51 ` Junio C Hamano
0 siblings, 1 reply; 2+ messages in thread
From: Anders Kaseorg @ 2026-11-11 7:55 UTC (permalink / raw)
To: Junio C Hamano; +Cc: git, Anders Kaseorg
Fixes a test failure when running inside a trash directory that
already contains w2 as a substring, as can be reproduced with
./t2401-worktree-prune.sh --root=/tmp/foow2bar
Fixes: 4a3ce479ce7c ("worktree: prune duplicate entries referencing same worktree path")
Signed-off-by: Anders Kaseorg <andersk@mit.edu>
---
t/t2401-worktree-prune.sh | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/t/t2401-worktree-prune.sh b/t/t2401-worktree-prune.sh
index 3d28c7f06b..5a2c998513 100755
--- a/t/t2401-worktree-prune.sh
+++ b/t/t2401-worktree-prune.sh
@@ -99,8 +99,7 @@ test_expect_success 'prune duplicate (linked/linked)' '
test_when_finished rm -fr .git/worktrees w1 w2 &&
git worktree add --detach w1 &&
git worktree add --detach w2 &&
- sed "s/w2/w1/" .git/worktrees/w2/gitdir >.git/worktrees/w2/gitdir.new &&
- mv .git/worktrees/w2/gitdir.new .git/worktrees/w2/gitdir &&
+ cp .git/worktrees/w1/gitdir .git/worktrees/w2/gitdir &&
git worktree prune --verbose 2>actual &&
test_i18ngrep "duplicate entry" actual &&
test -d .git/worktrees/w1 &&
---
base-commit: da8fb6be5594b4a06ef2cc2ff7a5363a6fac2b5a
change-id: 20261110-t2401-substitution-3ab4819833a1
Best regards,
--
Anders Kaseorg <andersk@mit.edu>
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] t2401: fix misfiring substitution when path contains w2
2026-11-11 7:55 [PATCH] t2401: fix misfiring substitution when path contains w2 Anders Kaseorg
@ 2026-11-11 16:51 ` Junio C Hamano
0 siblings, 0 replies; 2+ messages in thread
From: Junio C Hamano @ 2026-11-11 16:51 UTC (permalink / raw)
To: Anders Kaseorg; +Cc: git
"Anders Kaseorg" <andersk@mit.edu> writes:
> - sed "s/w2/w1/" .git/worktrees/w2/gitdir >.git/worktrees/w2/gitdir.new &&
> - mv .git/worktrees/w2/gitdir.new .git/worktrees/w2/gitdir &&
So we used to fabricate a new file by replacing the first substring
"w2" to "w1". Of course, if that "w2" is not the one we hyave in mind
but came from somewhere before ".../t/trash directory/", it would
not work. Well spotted.
> + cp .git/worktrees/w1/gitdir .git/worktrees/w2/gitdir &&
We have created a separate worktree "w1" just next to "w2", so
reusing what its gitdir says would give us the same. The "correct"
contents of w2/gitdif should point at "w2/.git" (with its full path)
but this "clobbered" file should point at "w1/.git" (which was what
the sed script was trying to do).
Makes sense.
> git worktree prune --verbose 2>actual &&
> test_i18ngrep "duplicate entry" actual &&
> test -d .git/worktrees/w1 &&
>
> ---
> base-commit: da8fb6be5594b4a06ef2cc2ff7a5363a6fac2b5a
> change-id: 20261110-t2401-substitution-3ab4819833a1
>
> Best regards,
> --
> Anders Kaseorg <andersk@mit.edu>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-11-11 16:51 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-11 7:55 [PATCH] t2401: fix misfiring substitution when path contains w2 Anders Kaseorg
2026-11-11 16:51 ` Junio C Hamano
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox