@@ -3244,21 +3244,40 @@ 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
32543275 * post-processing a filtered ref_array. These include:
32553276 * - filtering on reachability
3256- * - sorting the filtered results
32573277 * - including ahead-behind information in the formatted output
32583278 */
32593279 return !(filter -> reachable_from ||
32603280 filter -> unreachable_from ||
3261- sorting ||
32623281 format -> bases .nr ||
32633282 format -> is_base_tips .nr );
32643283}
@@ -3316,12 +3335,6 @@ static int memcasecmp(const void *vs1, const void *vs2, size_t n)
33163335 return 0 ;
33173336}
33183337
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-
33253338static int cmp_ref_sorting (struct ref_sorting * s , struct ref_array_item * a , struct ref_array_item * b )
33263339{
33273340 struct atom_value * va , * vb ;
0 commit comments