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>

René Scharfe committed Oct 1, 2016 at 18:19 UTC 7e65c75c31de751f58945a22e91e120c10ab6e87
1 file changed +2 -4
builtin/show-branch.c
+2 -4
@@ -353,8 +353,7 @@ static int compare_ref_name(const void *a_, const void *b_)
353
354 static void sort_ref_range(int bottom, int top)
355 {
356 - qsort(ref_name + bottom, top - bottom, sizeof(ref_name[0]),
357 - compare_ref_name);
356 + QSORT(ref_name + bottom, top - bottom, compare_ref_name);
357 }
358
359 static int append_ref(const char *refname, const struct object_id *oid,
@@ -540,8 +539,7 @@ static void append_one_rev(const char *av)
539 if (saved_matches == ref_name_cnt &&
540 ref_name_cnt < MAX_REVS)
541 error(_("no matching refs with %s"), av);
543 - if (saved_matches + 1 < ref_name_cnt)
544 - sort_ref_range(saved_matches, ref_name_cnt);
542 + sort_ref_range(saved_matches, ref_name_cnt);
543 return;
544 }
545 die("bad sha1 reference %s", av);