summaryrefslogtreecommitdiff
path: root/builtin/show-branch.c
diff options
context:
space:
mode:
authorRené Scharfe <l.s.r@web.de>2016-10-01 16:19:48 (GMT)
committerJunio C Hamano <gitster@pobox.com>2016-10-03 19:46:47 (GMT)
commit7e65c75c31de751f58945a22e91e120c10ab6e87 (patch)
treea422c99131c99bd8ccf5f45dcf95bc17bc5aa3b6 /builtin/show-branch.c
parent1b5294de406146c4ec321a59e07a5566c435cc2e (diff)
downloadgit-7e65c75c31de751f58945a22e91e120c10ab6e87.zip
git-7e65c75c31de751f58945a22e91e120c10ab6e87.tar.gz
git-7e65c75c31de751f58945a22e91e120c10ab6e87.tar.bz2
show-branch: use QSORT
Shorten the code by using QSORT instead of calling qsort(3) directly, as the former determines the element size automatically and checks if there are at least two elements to sort already. Signed-off-by: Rene Scharfe <l.s.r@web.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin/show-branch.c')
-rw-r--r--builtin/show-branch.c6
1 files changed, 2 insertions, 4 deletions
diff --git a/builtin/show-branch.c b/builtin/show-branch.c
index 623ca56..974f340 100644
--- a/builtin/show-branch.c
+++ b/builtin/show-branch.c
@@ -353,8 +353,7 @@ static int compare_ref_name(const void *a_, const void *b_)
static void sort_ref_range(int bottom, int top)
{
- qsort(ref_name + bottom, top - bottom, sizeof(ref_name[0]),
- compare_ref_name);
+ QSORT(ref_name + bottom, top - bottom, compare_ref_name);
}
static int append_ref(const char *refname, const struct object_id *oid,
@@ -540,8 +539,7 @@ static void append_one_rev(const char *av)
if (saved_matches == ref_name_cnt &&
ref_name_cnt < MAX_REVS)
error(_("no matching refs with %s"), av);
- if (saved_matches + 1 < ref_name_cnt)
- sort_ref_range(saved_matches, ref_name_cnt);
+ sort_ref_range(saved_matches, ref_name_cnt);
return;
}
die("bad sha1 reference %s", av);