Subject: Re: [PATCH v3] worktree: detect from secondary worktree if main worktree is bare

From: Junio C Hamano <[email-masked]>
Date: Fri, 31 Jan 2025 12:20:17 -0800

Olga Pilipenco <[email-masked]> writes:

>> Perhaps the logic is clear to those who diagnosed the problem, wrote
>> the patch, and reviewed it, in which case there is no reason to
>> reroll.  Perhaps it was just me to whom it was not obvious that
>> the purpose of "is_current" check was not about "are we looking at
>> the main worktree" but was about "if we are not in the main worktree,
>> we need this extra check".
>>
>> Thanks.
>
> You did a great job figuring it out and I agree it's confusing at
> first, but we tried our best to make it less confusing.
> `is_current` check is actually not necessary there, but having it there saves
> extra unnecessary calculations, also describes & fixes the exact scenario
> that didn't work (not being able to see main worktree as bare from a
> secondary worktree).

If I had to do a great job there, then the code does deserve to be
explained a bit better for later developers who wonder why it is
written in the way it is, perhaps we a single-liner comment?

Thanks.