Austin Morton <austin.morton@xxxxxxxxxxx> writes: [jc: swapped the blocks to chronological order, and trimmed parts that are not relevant to this reply]. > On Fri, Apr 29, 2022 at 8:19 PM Junio C Hamano <gitster@xxxxxxxxx> wrote: >> >> Austin Morton <austin.morton@xxxxxxxxxxx> 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.