Re: [PATCH 00/11] git worktree (re)move

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Nov 16, 2016 at 8:05 PM, Duy Nguyen <pclouds@xxxxxxxxx> wrote:
> 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



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]