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.