git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Caleb White <cdwhite3@pm.me>
To: Junio C Hamano <gitster@pobox.com>
Cc: rsbecker@nexbridge.com, 'Eric Sunshine' <sunshine@sunshineco.com>,
	'shejialuo' <shejialuo@gmail.com>,
	git@vger.kernel.org
Subject: Re: [PATCH v2 0/3] Ensure unique worktree ids across repositories
Date: Tue, 03 Dec 2024 05:31:46 +0000	[thread overview]
Message-ID: <D61TI8S0M79X.1YEUCB7FI6CC@pm.me> (raw)
In-Reply-To: <xmqqiks1e5zs.fsf@gitster.g>

On Mon Dec 2, 2024 at 10:37 PM CST, Junio C Hamano wrote:
> 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.

> 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,


  reply	other threads:[~2024-12-03  5:31 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-11-29 22:37 [PATCH v2 0/3] Ensure unique worktree ids across repositories Caleb White
2024-11-29 22:37 ` [PATCH v2 1/3] worktree: add worktree with unique suffix Caleb White
2024-11-29 22:37 ` [PATCH v2 2/3] worktree: rename worktree id during worktree move Caleb White
2024-11-29 22:37 ` [PATCH v2 3/3] worktree: add id to `worktree list` output Caleb White
2024-11-29 22:54 ` [PATCH v2 0/3] Ensure unique worktree ids across repositories rsbecker
2024-11-29 23:13   ` Caleb White
2024-11-29 23:17     ` rsbecker
2024-11-29 23:29       ` Caleb White
2024-11-29 23:44         ` rsbecker
2024-11-30  0:08           ` Caleb White
2024-11-30  0:38             ` rsbecker
2024-11-30 16:08               ` Caleb White
2024-11-30 17:16                 ` rsbecker
2024-12-02  2:00 ` Junio C Hamano
2024-12-02 11:46   ` shejialuo
2024-12-03  0:46     ` Junio C Hamano
2024-12-03  0:56       ` Eric Sunshine
2024-12-03  1:46         ` Junio C Hamano
2024-12-03  1:53           ` rsbecker
2024-12-03  2:30             ` Junio C Hamano
2024-12-03  3:42               ` Caleb White
2024-12-03  4:37                 ` Junio C Hamano
2024-12-03  5:31                   ` Caleb White [this message]
2024-12-03  1:24       ` shejialuo

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=D61TI8S0M79X.1YEUCB7FI6CC@pm.me \
    --to=cdwhite3@pm.me \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=rsbecker@nexbridge.com \
    --cc=shejialuo@gmail.com \
    --cc=sunshine@sunshineco.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).