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

Re: Able to checkout same branch in multiple worktrees when using symbolic-refs

From
Junio C Hamano <gitster@pobox.com>
Date
May 2, 2022, 18:30 UTC
Message-ID
<xmqq7d73zt0x.fsf@gitster.g>
In-Reply-To
<CAAir=1NY=98Z_cTrEyUn6tcPFR3UGNUmXs=2hg27LMGijGZpUw@mail.gmail.com>
Austin Morton <austin.morton@aquatic.com> writes:

[jc: swapped the blocks to chronological order, and trimmed parts that are not relevant to this reply].

Show 14 quoted lines
> On Fri, Apr 29, 2022 at 8:19 PM Junio C Hamano <gitster@pobox.com> wrote:
>>
>> Austin Morton <austin.morton@aquatic.com> writes:
>>
>> I also suspect there is no way, other than scanning _all_ the local
>> branches, to see if some other branch aliases the branch we are
>> about to check out.  It may potentially be somewhat expensive.
>
> I don't know why you would need to scan all the local branches, unless
> that is what "git worktree list" ends up doing under the hood?
> ...
> Seems like you would "just" need to resolve the symbolic-ref in the
> same way that the worktree code does when checking against existing
> worktrees in find_shared_symref during checkout.
Yeah, you're right.

You would scan all the worktrees instead of asking all the local branches "Are you a symlink that points at a branch I am about to check out? If so, yell loudly to stop me."

>> But it would be nice if it can get fixed in inexpensively.
>>
>> Thanks for a report.
So, yeah, it may be doable to fix it inexpensively.
Patches welcome ;-)
Thanks.
Previous: Austin Morton
Message 4 of 4 in “Able to checkout same branch in multiple worktrees when using symbolic-refs”
  1. Austin MortonApr 29, 2022
  2. Junio C HamanoApr 29, 2022
  3. Austin MortonMay 2, 2022
  4. Junio C HamanoMay 2, 2022

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.