@@ -3244,21 +3244,40 @@ int filter_refs(struct ref_array *array, struct ref_filter *filter, unsigned int
3244
3244
return ret ;
3245
3245
}
3246
3246
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
+
3247
3253
static inline int can_do_iterative_format (struct ref_filter * filter ,
3248
3254
struct ref_sorting * sorting ,
3249
3255
struct ref_format * format )
3250
3256
{
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
+
3251
3272
/*
3252
3273
* Filtering & formatting results within a single ref iteration
3253
3274
* callback is not compatible with options that require
3254
3275
* post-processing a filtered ref_array. These include:
3255
3276
* - filtering on reachability
3256
- * - sorting the filtered results
3257
3277
* - including ahead-behind information in the formatted output
3258
3278
*/
3259
3279
return !(filter -> reachable_from ||
3260
3280
filter -> unreachable_from ||
3261
- sorting ||
3262
3281
format -> bases .nr ||
3263
3282
format -> is_base_tips .nr );
3264
3283
}
@@ -3316,12 +3335,6 @@ static int memcasecmp(const void *vs1, const void *vs2, size_t n)
3316
3335
return 0 ;
3317
3336
}
3318
3337
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
-
3325
3338
static int cmp_ref_sorting (struct ref_sorting * s , struct ref_array_item * a , struct ref_array_item * b )
3326
3339
{
3327
3340
struct atom_value * va , * vb ;
0 commit comments