On Thu, Nov 24, 2016 at 12:16 AM, Junio C Hamano <gitster@xxxxxxxxx> 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() > 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