Imported Upstream version 2.27.0
[platform/upstream/git.git] / ref-filter.c
index b1812cb..bf7b702 100644 (file)
@@ -1976,10 +1976,9 @@ static int for_each_fullref_in_pattern(struct ref_filter *filter,
 }
 
 /*
- * Given a ref (sha1, refname), check if the ref belongs to the array
- * of sha1s. If the given ref is a tag, check if the given tag points
- * at one of the sha1s in the given sha1 array.
- * the given sha1_array.
+ * Given a ref (oid, refname), check if the ref belongs to the array
+ * of oids. If the given ref is a tag, check if the given tag points
+ * at one of the oids in the given oid array.
  * NEEDSWORK:
  * 1. Only a single level of inderection is obtained, we might want to
  * change this to account for multiple levels (e.g. annotated tags
@@ -2296,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;
        }
@@ -2315,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)