Skip to content

Commit 1df2046

Browse files
committed
Merge branch 'nd/qsort-in-merge-recursive' into maint
Code simplification. * nd/qsort-in-merge-recursive: merge-recursive.c: use string_list_sort instead of qsort
2 parents 48d23c1 + fa6ca11 commit 1df2046

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

merge-recursive.c

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -390,12 +390,10 @@ static struct string_list *get_unmerged(void)
390390
return unmerged;
391391
}
392392

393-
static int string_list_df_name_compare(const void *a, const void *b)
393+
static int string_list_df_name_compare(const char *one, const char *two)
394394
{
395-
const struct string_list_item *one = a;
396-
const struct string_list_item *two = b;
397-
int onelen = strlen(one->string);
398-
int twolen = strlen(two->string);
395+
int onelen = strlen(one);
396+
int twolen = strlen(two);
399397
/*
400398
* Here we only care that entries for D/F conflicts are
401399
* adjacent, in particular with the file of the D/F conflict
@@ -408,8 +406,8 @@ static int string_list_df_name_compare(const void *a, const void *b)
408406
* since in other cases any changes in their order due to
409407
* sorting cause no problems for us.
410408
*/
411-
int cmp = df_name_compare(one->string, onelen, S_IFDIR,
412-
two->string, twolen, S_IFDIR);
409+
int cmp = df_name_compare(one, onelen, S_IFDIR,
410+
two, twolen, S_IFDIR);
413411
/*
414412
* Now that 'foo' and 'foo/bar' compare equal, we have to make sure
415413
* that 'foo' comes before 'foo/bar'.
@@ -453,8 +451,8 @@ static void record_df_conflict_files(struct merge_options *o,
453451
string_list_append(&df_sorted_entries, next->string)->util =
454452
next->util;
455453
}
456-
qsort(df_sorted_entries.items, entries->nr, sizeof(*entries->items),
457-
string_list_df_name_compare);
454+
df_sorted_entries.cmp = string_list_df_name_compare;
455+
string_list_sort(&df_sorted_entries);
458456

459457
string_list_clear(&o->df_conflict_file_set, 1);
460458
for (i = 0; i < df_sorted_entries.nr; i++) {

0 commit comments

Comments
 (0)