Re: [PATCH 3/3] worktree list: keep the list sorted
- From
Duy Nguyen <pclouds@gmail.com>
- Date
- Nov 25, 2016, 12:19 UTC
- Message-ID
- <CACsJy8C-5f-PErg6zx5OuURaA717o_g_RddjvwMUnO+vKCHrNA@mail.gmail.com>
- In-Reply-To
- <xmqqwpfum801.fsf@gitster.mtv.corp.google.com>
On Thu, Nov 24, 2016 at 12:16 AM, Junio C Hamano <gitster@pobox.com> wrote:
> More importantly, perhaps get_worktrees() should learn to take an > optional pointer to int that returns how many items are in the list?
My first thought was "yeah I remember there are many counting loop like this" then grepped and realized this is the only place. For now I think it's ok to leave it as is. When the second place does the same, we'll change get_worktrees()
Show 5 quoted lines
> Alternatively, other existing callers of the function do not care > about the order, so it may not be such a good idea to always sort > the result, but it may be a good idea to teach it to take a boolean > that signals that the list should be sorted in a "natural order", > which is how "worktree list" would show them to the user?
OK. I'll make it a bit flag, not a boolean though, to avoid changing all call sites next time.
-- Duy