summaryrefslogtreecommitdiff
path: root/ref-filter.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2020-05-08 21:25:04 (GMT)
committerJunio C Hamano <gitster@pobox.com>2020-05-08 21:25:04 (GMT)
commit6de1630898838b62b97617323a07eb6fe9618a7e (patch)
treefd5c44e8d439d57b02cb93f36b57a65ada759d92 /ref-filter.c
parent1260f819aa757c184b2d7afd6f27ad48f625677b (diff)
parent7c5045fc180ed09ed4cb5065955acddc1dd50163 (diff)
downloadgit-6de1630898838b62b97617323a07eb6fe9618a7e.zip
git-6de1630898838b62b97617323a07eb6fe9618a7e.tar.gz
git-6de1630898838b62b97617323a07eb6fe9618a7e.tar.bz2
Merge branch 'jk/for-each-ref-multi-key-sort-fix'
"git branch" and other "for-each-ref" variants accepted multiple --sort=<key> options in the increasing order of precedence, but it had a few breakages around "--ignore-case" handling, and tie-breaking with the refname, which have been fixed. * jk/for-each-ref-multi-key-sort-fix: ref-filter: apply fallback refname sort only after all user sorts ref-filter: apply --ignore-case to all sorting keys
Diffstat (limited to 'ref-filter.c')
-rw-r--r--ref-filter.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/ref-filter.c b/ref-filter.c
index 3577683..bf7b702 100644
--- a/ref-filter.c
+++ b/ref-filter.c
@@ -2295,7 +2295,7 @@ static int cmp_ref_sorting(struct ref_sorting *s, struct ref_array_item *a, stru
if (va->value < vb->value)
cmp = -1;
else if (va->value == vb->value)
- cmp = cmp_fn(a->refname, b->refname);
+ cmp = 0;
else
cmp = 1;
}
@@ -2314,7 +2314,16 @@ static int compare_refs(const void *a_, const void *b_, void *ref_sorting)
if (cmp)
return cmp;
}
- return 0;
+ s = ref_sorting;
+ return s && s->ignore_case ?
+ strcasecmp(a->refname, b->refname) :
+ strcmp(a->refname, b->refname);
+}
+
+void ref_sorting_icase_all(struct ref_sorting *sorting, int flag)
+{
+ for (; sorting; sorting = sorting->next)
+ sorting->ignore_case = !!flag;
}
void ref_array_sort(struct ref_sorting *sorting, struct ref_array *array)