git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] t2401: fix misfiring substitution when path contains w2

From
Junio C Hamano <gitster@pobox.com>
Date
Nov 11, 2026, 16:51 UTC
Message-ID
<xmqqjymjnwg8.fsf@gitster.g>
In-Reply-To
<20261110-t2401-substitution-v1-1-32f3524f2b92@mit.edu>
"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.
Show 11 quoted lines
>  	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>
Previous: Anders Kaseorg
Message 2 of 2 in “t2401: fix misfiring substitution when path contains w2”
  1. t2401: fix misfiring substitution when path contains w2Anders Kaseorg, Nov 11, 2026
  2. Junio C HamanoNov 11, 2026

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.