Re: [PATCH 6/8] worktree: prune linked worktree referencing main worktree path
On Mon, Jun 8, 2020 at 5:59 PM Junio C Hamano <gitster@pobox.com> wrote:
Show 17 quoted lines
> Eric Sunshine <sunshine@sunshineco.com> writes:
> > + /* paths same; main worktee (util==0) sorts above all others */
>
> And the reason why prune_cmp() tiebreaks entries with the same .string
> (i.e. "path") so that the primary worktree comes early is because ...
>
> > prune_dups(&kept);
>
> ... deduping is done by later entries with the same path as an
> earlier one, keeping the earliest one among the ones with the same
> path. We want the primary worktree to survive, or we'd be in deep
> yoghurt.
>
> That reason is more important to comment in prune_cmp() than the
> hint that !util is for primary worktree. IOW, "why do we sort the
> primary one early?" is more important than "by inspecting .util
> field, we sort primary one early" (the latter lacks "why").
I'll update the comment to explain this.
Thanks for the review.