Re: [PATCH 00/11] git worktree (re)move
- From
Duy Nguyen <pclouds@gmail.com>
- Date
- Nov 16, 2016, 13:11 UTC
- Message-ID
- <CACsJy8DOT_4N_48UaoYK61G_8JUaXbEs7N=n24CH2q1GN=++5g@mail.gmail.com>
- In-Reply-To
- <20161116130533.GA5393@ash>
On Wed, Nov 16, 2016 at 8:05 PM, Duy Nguyen <pclouds@gmail.com> wrote:
Show 26 quoted lines
> diff --git a/worktree.c b/worktree.c
> index f7869f8..fe92d6f 100644
> --- a/worktree.c
> +++ b/worktree.c
> @@ -173,6 +173,13 @@ static void mark_current_worktree(struct worktree **worktrees)
> free(git_dir);
> }
>
> +static int compare_worktree(const void *a_, const void *b_)
> +{
> + const struct worktree *const *a = a_;
> + const struct worktree *const *b = b_;
> + return fspathcmp((*a)->path, (*b)->path);
> +}
> +
> struct worktree **get_worktrees(void)
> {
> struct worktree **list = NULL;
> @@ -205,6 +212,11 @@ struct worktree **get_worktrees(void)
> ALLOC_GROW(list, counter + 1, alloc);
> list[counter] = NULL;
>
> + /*
> + * don't sort the first item (main worktree), which will
> + * always be the first
> + */Urgh.. I should review my patches more carefully before sending out :( The main worktree could be missing (failing to parse HEAD) so I need a better trick than simply assuming the first item is the main worktree here. Tests did not catch this, naturally..
> + qsort(list + 1, counter - 1, sizeof(*list), compare_worktree); > mark_current_worktree(list); > return list; > }
-- Duy