{"thread":{"id":"66827","subject":"[PATCH] t2401: fix misfiring substitution when path contains w2","startedAt":"2026-11-11T07:55:58Z","lastAt":"2026-11-11T16:51:03Z","messageCount":2,"participants":["Anders Kaseorg","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"558160","messageId":"20261110-t2401-substitution-v1-1-32f3524f2b92@mit.edu","threadId":"66827","inReplyTo":null,"subject":"[PATCH] t2401: fix misfiring substitution when path contains w2","fromName":"Anders Kaseorg","fromEmail":"andersk@mit.edu","sentAt":"2026-11-11T07:55:58Z","receivedAt":"2026-11-11T07:55:58Z","isPatch":true,"sender":{"key":"andersk@mit.edu","avatar":"https://avatars.githubusercontent.com/u/26471?v=4"},"body":"Fixes a test failure when running inside a trash directory that\nalready contains w2 as a substring, as can be reproduced with\n\n  ./t2401-worktree-prune.sh --root=/tmp/foow2bar\n\nFixes: 4a3ce479ce7c (\"worktree: prune duplicate entries referencing same worktree path\")\nSigned-off-by: Anders Kaseorg <andersk@mit.edu>\n---\n t/t2401-worktree-prune.sh | 3 +--\n 1 file changed, 1 insertion(+), 2 deletions(-)\n\ndiff --git a/t/t2401-worktree-prune.sh b/t/t2401-worktree-prune.sh\nindex 3d28c7f06b..5a2c998513 100755\n--- a/t/t2401-worktree-prune.sh\n+++ b/t/t2401-worktree-prune.sh\n@@ -99,8 +99,7 @@ test_expect_success 'prune duplicate (linked/linked)' '\n \ttest_when_finished rm -fr .git/worktrees w1 w2 &&\n \tgit worktree add --detach w1 &&\n \tgit worktree add --detach w2 &&\n-\tsed \"s/w2/w1/\" .git/worktrees/w2/gitdir >.git/worktrees/w2/gitdir.new &&\n-\tmv .git/worktrees/w2/gitdir.new .git/worktrees/w2/gitdir &&\n+\tcp .git/worktrees/w1/gitdir .git/worktrees/w2/gitdir &&\n \tgit worktree prune --verbose 2>actual &&\n \ttest_i18ngrep \"duplicate entry\" actual &&\n \ttest -d .git/worktrees/w1 &&\n\n---\nbase-commit: da8fb6be5594b4a06ef2cc2ff7a5363a6fac2b5a\nchange-id: 20261110-t2401-substitution-3ab4819833a1\n\nBest regards,\n--  \nAnders Kaseorg <andersk@mit.edu>\n\n\n"},{"id":"558238","messageId":"xmqqjymjnwg8.fsf@gitster.g","threadId":"66827","inReplyTo":"20261110-t2401-substitution-v1-1-32f3524f2b92@mit.edu","subject":"Re: [PATCH] t2401: fix misfiring substitution when path contains w2","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2026-11-11T16:51:03Z","receivedAt":"2026-11-11T16:51:03Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"Anders Kaseorg\" <andersk@mit.edu> writes:\n\n> -\tsed \"s/w2/w1/\" .git/worktrees/w2/gitdir >.git/worktrees/w2/gitdir.new &&\n> -\tmv .git/worktrees/w2/gitdir.new .git/worktrees/w2/gitdir &&\n\nSo we used to fabricate a new file by replacing the first substring\n\"w2\" to \"w1\".  Of course, if that \"w2\" is not the one we hyave in mind\nbut came from somewhere before \".../t/trash directory/\", it would\nnot work.  Well spotted.\n\n> +\tcp .git/worktrees/w1/gitdir .git/worktrees/w2/gitdir &&\n\nWe have created a separate worktree \"w1\" just next to \"w2\", so\nreusing what its gitdir says would give us the same.  The \"correct\"\ncontents of w2/gitdif should point at \"w2/.git\" (with its full path)\nbut this \"clobbered\" file should point at \"w1/.git\" (which was what\nthe sed script was trying to do).\n\nMakes sense.\n\n>  \tgit worktree prune --verbose 2>actual &&\n>  \ttest_i18ngrep \"duplicate entry\" actual &&\n>  \ttest -d .git/worktrees/w1 &&\n>\n> ---\n> base-commit: da8fb6be5594b4a06ef2cc2ff7a5363a6fac2b5a\n> change-id: 20261110-t2401-substitution-3ab4819833a1\n>\n> Best regards,\n> --  \n> Anders Kaseorg <andersk@mit.edu>\n\n"}]}