aboutsummaryrefslogtreecommitdiff
path: root/merge-recursive.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2017-01-17 15:19:03 -0800
committerJunio C Hamano <gitster@pobox.com>2017-01-17 15:19:03 -0800
commit1df2046d270011837c904d2b568b599bf61cdb87 (patch)
tree58103c57c22f3012bb7cec3b14e94573780c3b8a /merge-recursive.c
parent48d23c12e7329213e0dfd73bbffc6ad05efcaf9d (diff)
parentfa6ca11105ccb46b785fd4ed58c333d5ad7f1774 (diff)
downloadgit-1df2046d270011837c904d2b568b599bf61cdb87.tar.gz
git-1df2046d270011837c904d2b568b599bf61cdb87.tar.xz
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
Diffstat (limited to 'merge-recursive.c')
-rw-r--r--merge-recursive.c16
1 files changed, 7 insertions, 9 deletions
diff --git a/merge-recursive.c b/merge-recursive.c
index 214f5a693..23d6992f4 100644
--- a/merge-recursive.c
+++ b/merge-recursive.c
@@ -390,12 +390,10 @@ static struct string_list *get_unmerged(void)
return unmerged;
}
-static int string_list_df_name_compare(const void *a, const void *b)
+static int string_list_df_name_compare(const char *one, const char *two)
{
- const struct string_list_item *one = a;
- const struct string_list_item *two = b;
- int onelen = strlen(one->string);
- int twolen = strlen(two->string);
+ int onelen = strlen(one);
+ int twolen = strlen(two);
/*
* Here we only care that entries for D/F conflicts are
* 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)
* since in other cases any changes in their order due to
* sorting cause no problems for us.
*/
- int cmp = df_name_compare(one->string, onelen, S_IFDIR,
- two->string, twolen, S_IFDIR);
+ int cmp = df_name_compare(one, onelen, S_IFDIR,
+ two, twolen, S_IFDIR);
/*
* Now that 'foo' and 'foo/bar' compare equal, we have to make sure
* that 'foo' comes before 'foo/bar'.
@@ -453,8 +451,8 @@ static void record_df_conflict_files(struct merge_options *o,
string_list_append(&df_sorted_entries, next->string)->util =
next->util;
}
- qsort(df_sorted_entries.items, entries->nr, sizeof(*entries->items),
- string_list_df_name_compare);
+ df_sorted_entries.cmp = string_list_df_name_compare;
+ string_list_sort(&df_sorted_entries);
string_list_clear(&o->df_conflict_file_set, 1);
for (i = 0; i < df_sorted_entries.nr; i++) {