merge-recursive.c: use string_list_sort instead of qsort
[gitweb.git] / merge-recursive.c
index e5243c2b766881b5b4c83a16d9caebbd392c798a..6802d86c14730f03f7a220eb21ed969a7ea87fbf 100644 (file)
@@ -73,12 +73,9 @@ static struct tree *shift_tree_object(struct tree *one, struct tree *two,
 static struct commit *make_virtual_commit(struct tree *tree, const char *comment)
 {
        struct commit *commit = alloc_commit_node();
-       struct merge_remote_desc *desc = xmalloc(sizeof(*desc));
 
-       desc->name = comment;
-       desc->obj = (struct object *)commit;
+       set_merge_remote_desc(commit, comment, (struct object *)commit);
        commit->tree = tree;
-       commit->util = desc;
        commit->object.parsed = 1;
        return commit;
 }
@@ -205,11 +202,11 @@ static void output_commit_title(struct merge_options *o, struct commit *commit)
                strbuf_addf(&o->obuf, "virtual %s\n",
                        merge_remote_util(commit)->name);
        else {
-               strbuf_addf(&o->obuf, "%s ",
-                       find_unique_abbrev(commit->object.oid.hash,
-                               DEFAULT_ABBREV));
+               strbuf_add_unique_abbrev(&o->obuf, commit->object.oid.hash,
+                                        DEFAULT_ABBREV);
+               strbuf_addch(&o->obuf, ' ');
                if (parse_commit(commit) != 0)
-                       strbuf_addf(&o->obuf, _("(bad commit)\n"));
+                       strbuf_addstr(&o->obuf, _("(bad commit)\n"));
                else {
                        const char *title;
                        const char *msg = get_commit_buffer(commit, NULL);
@@ -391,12 +388,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
@@ -409,8 +404,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'.
@@ -454,8 +449,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++) {