Re: [PATCH 3/3] worktree list: keep the list sorted

2016-11-25 Thread Duy Nguyen
On Thu, Nov 24, 2016 at 12:16 AM, Junio C Hamano 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 realize

Re: [PATCH 3/3] worktree list: keep the list sorted

2016-11-23 Thread Junio C Hamano
Nguyễn Thái Ngọc Duy writes: > + for (i = nr = 0; worktrees[i]; i++) > + nr++; > + > + /* > + * don't sort the first item (main worktree), which will > + * always be the first > + */ > + QSORT(worktree

[PATCH 3/3] worktree list: keep the list sorted

2016-11-22 Thread Nguyễn Thái Ngọc Duy
It makes it easier to write tests for. But it should also be good for the user since locating a worktree by eye would be easier once they notice this. Signed-off-by: Nguyễn Thái Ngọc Duy --- builtin/worktree.c | 18 +- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a