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

Re: [PATCH v2 0/3] Ensure unique worktree ids across repositories

From
Caleb White <cdwhite3@pm.me>
Date
Dec 3, 2024, 05:31 UTC
Message-ID
<D61TI8S0M79X.1YEUCB7FI6CC@pm.me>
In-Reply-To
<xmqqiks1e5zs.fsf@gitster.g>
On Mon Dec 2, 2024 at 10:37 PM CST, Junio C Hamano wrote:
Show 16 quoted lines
> Caleb White <cdwhite3@pm.me> writes:
>
>> You're correct in that the worktree ids are only relevant within the
>> context of a single repository. However, I've already demonstrated that
>> it's possible for a repository to "repair" (i.e., take over) a worktree
>> belonging to another repository if the ids match (inferred backlink).
>
> I know.  But isn't that a BUG in the code that "repair"s?  If a
> worktree had a name 'develop' that was OK in the context of
> repository X, and when you "repair" things so that it becomes one of
> the worktrees of a different repository Y, the "repair" operation is
> what MUST make sure that the worktree that used to be known as
> 'develop' to repository X does not interfere any existing worktrees
> that is attached to the repository Y.  If the repository Y already
> had a worktree called 'develop', the "repair" operation must make
> sure that the newly adopted worktree would get a different name.

No, this is incorrect---there should be no reason to "repair" a worktree from another repository in the first place. That would be undefined behavior and is indicative of a user mistake or unintentional repair (e.g., it would make no sense for the php-src repository to repair a worktree from this git repository). The repair operation is only intended to be used with worktrees of the same repository.

Show 8 quoted lines
> But then, the concern is exactly the same when you try to create a
> new worktree (no "repair" involved) in repository Y and try to give
> it a name 'develop', isn't it?  You have to make sure that there is
> no worktree that is called 'develop' in the repository Y before
> giving it the name.  Is it broken?  If not, what are we doing to
> make sure we won't give the name 'develop' to the new worktree?
> Certainly we do not use any hash or random number for that, so why
> does this new series need to use a random number?

We currently suffix an auto incrementing number in this use case, so you can have two `develop` worktrees (located in different directories of course), and one will have an id of `develop` and the other will have an id of `develop1`.

Best,
Previous: Junio C HamanoNext: shejialuo
Message 23 of 24 in “Ensure unique worktree ids across repositories”
  1. 0/3 Ensure unique worktree ids across repositoriesCaleb White, Nov 29, 2024
  2. 1/3 worktree: add worktree with unique suffixCaleb White, Nov 29, 2024
  3. 2/3 worktree: rename worktree id during worktree moveCaleb White, Nov 29, 2024
  4. 3/3 worktree: add id to `worktree list` outputCaleb White, Nov 29, 2024
  5. rsbecker@nexbridge.comNov 29, 2024
  6. Caleb WhiteNov 29, 2024
  7. rsbecker@nexbridge.comNov 29, 2024
  8. Caleb WhiteNov 29, 2024
  9. rsbecker@nexbridge.comNov 29, 2024
  10. Caleb WhiteNov 30, 2024
  11. rsbecker@nexbridge.comNov 30, 2024
  12. Caleb WhiteNov 30, 2024
  13. rsbecker@nexbridge.comNov 30, 2024
  14. Junio C HamanoDec 2, 2024
  15. shejialuoDec 2, 2024
  16. Junio C HamanoDec 3, 2024
  17. Eric SunshineDec 3, 2024
  18. Junio C HamanoDec 3, 2024
  19. rsbecker@nexbridge.comDec 3, 2024
  20. Junio C HamanoDec 3, 2024
  21. Caleb WhiteDec 3, 2024
  22. Junio C HamanoDec 3, 2024
  23. Caleb WhiteDec 3, 2024
  24. shejialuoDec 3, 2024

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.