@@ -3244,10 +3244,31 @@ int filter_refs(struct ref_array *array, struct ref_filter *filter, unsigned int
32443244 return ret ;
32453245}
32463246
3247+ struct ref_sorting {
3248+ struct ref_sorting * next ;
3249+ int atom ; /* index into used_atom array (internal) */
3250+ enum ref_sorting_order sort_flags ;
3251+ };
3252+
32473253static inline int can_do_iterative_format (struct ref_filter * filter ,
32483254 struct ref_sorting * sorting ,
32493255 struct ref_format * format )
32503256{
3257+ /*
3258+ * Reference backends sort patterns lexicographically by refname, so if
3259+ * the sorting options ask for exactly that we are able to do iterative
3260+ * formatting.
3261+ *
3262+ * Note that we do not have to worry about multiple name patterns,
3263+ * either. Those get sorted and deduplicated eventually in
3264+ * `refs_for_each_fullref_in_prefixes()`, so we return names in the
3265+ * correct ordering here, too.
3266+ */
3267+ if (sorting && (sorting -> next ||
3268+ sorting -> sort_flags ||
3269+ used_atom [sorting -> atom ].atom_type != ATOM_REFNAME ))
3270+ return 0 ;
3271+
32513272 /*
32523273 * Filtering & formatting results within a single ref iteration
32533274 * callback is not compatible with options that require
@@ -3258,7 +3279,6 @@ static inline int can_do_iterative_format(struct ref_filter *filter,
32583279 */
32593280 return !(filter -> reachable_from ||
32603281 filter -> unreachable_from ||
3261- sorting ||
32623282 format -> bases .nr ||
32633283 format -> is_base_tips .nr );
32643284}
@@ -3316,12 +3336,6 @@ static int memcasecmp(const void *vs1, const void *vs2, size_t n)
33163336 return 0 ;
33173337}
33183338
3319- struct ref_sorting {
3320- struct ref_sorting * next ;
3321- int atom ; /* index into used_atom array (internal) */
3322- enum ref_sorting_order sort_flags ;
3323- };
3324-
33253339static int cmp_ref_sorting (struct ref_sorting * s , struct ref_array_item * a , struct ref_array_item * b )
33263340{
33273341 struct atom_value * va , * vb ;
0 commit comments