diff options
author | Eric Sunshine <sunshine@sunshineco.com> | 2020-06-20 02:35:43 +0300 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2020-06-22 20:30:29 +0300 |
commit | d9c54c2bbf684ca3903bc2227c81f657a557d8b8 (patch) | |
tree | f92b97425460ce1f035f4c4839e16e46dd441931 /worktree.c | |
parent | 810382ed378731314c03627a8a2d8962b814ad17 (diff) |
worktree: drop get_worktrees() special-purpose sorting option
Of all the clients of get_worktrees(), only "git worktree list" wants
the list sorted in a very specific way; other clients simply don't care
about the order. Rather than imbuing get_worktrees() with special
knowledge about how various clients -- now and in the future -- may want
the list sorted, drop the sorting capability altogether and make it the
client's responsibility to sort the list if needed.
Signed-off-by: Eric Sunshine <sunshine@sunshineco.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'worktree.c')
-rw-r--r-- | worktree.c | 14 |
1 files changed, 0 insertions, 14 deletions
diff --git a/worktree.c b/worktree.c index eba4fd3a03..42cabc5403 100644 --- a/worktree.c +++ b/worktree.c @@ -123,13 +123,6 @@ 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(unsigned flags) { struct worktree **list = NULL; @@ -161,13 +154,6 @@ struct worktree **get_worktrees(unsigned flags) ALLOC_GROW(list, counter + 1, alloc); list[counter] = NULL; - if (flags & GWT_SORT_LINKED) - /* - * don't sort the first item (main worktree), which will - * always be the first - */ - QSORT(list + 1, counter - 1, compare_worktree); - mark_current_worktree(list); return list; } |