t7810: fix duplicated test title
[gitweb.git] / notes-merge.c
index ec02da1329c7ed5d792ee358ce838ec869f8cb7f..0d38a1b17d8399c7acf6355d598f0a50d0ec1d3b 100644 (file)
@@ -351,7 +351,7 @@ static int ll_merge_in_worktree(struct notes_merge_options *o,
        read_mmblob(&remote, p->remote);
 
        status = ll_merge(&result_buf, sha1_to_hex(p->obj), &base, NULL,
-                         &local, o->local_ref, &remote, o->remote_ref, 0);
+                         &local, o->local_ref, &remote, o->remote_ref, NULL);
 
        free(base.ptr);
        free(local.ptr);
@@ -530,7 +530,7 @@ static int merge_from_diffs(struct notes_merge_options *o,
 }
 
 void create_notes_commit(struct notes_tree *t, struct commit_list *parents,
-                        const char *msg, unsigned char *result_sha1)
+                        const struct strbuf *msg, unsigned char *result_sha1)
 {
        unsigned char tree_sha1[20];
 
@@ -573,9 +573,10 @@ int notes_merge(struct notes_merge_options *o,
               o->local_ref, o->remote_ref);
 
        /* Dereference o->local_ref into local_sha1 */
-       if (!resolve_ref(o->local_ref, local_sha1, 0, NULL))
+       if (read_ref_full(o->local_ref, local_sha1, 0, NULL))
                die("Failed to resolve local notes ref '%s'", o->local_ref);
-       else if (!check_ref_format(o->local_ref) && is_null_sha1(local_sha1))
+       else if (!check_refname_format(o->local_ref, 0) &&
+               is_null_sha1(local_sha1))
                local = NULL; /* local_sha1 == null_sha1 indicates unborn ref */
        else if (!(local = lookup_commit_reference(local_sha1)))
                die("Could not parse local commit %s (%s)",
@@ -588,7 +589,7 @@ int notes_merge(struct notes_merge_options *o,
                 * Failed to get remote_sha1. If o->remote_ref looks like an
                 * unborn ref, perform the merge using an empty notes tree.
                 */
-               if (!check_ref_format(o->remote_ref)) {
+               if (!check_refname_format(o->remote_ref, 0)) {
                        hashclr(remote_sha1);
                        remote = NULL;
                } else {
@@ -667,7 +668,7 @@ int notes_merge(struct notes_merge_options *o,
                struct commit_list *parents = NULL;
                commit_list_insert(remote, &parents); /* LIFO order */
                commit_list_insert(local, &parents);
-               create_notes_commit(local_tree, parents, o->commit_msg.buf,
+               create_notes_commit(local_tree, parents, &o->commit_msg,
                                    result_sha1);
        }
 
@@ -692,9 +693,10 @@ int notes_merge_commit(struct notes_merge_options *o,
         * Finally store the new commit object SHA1 into 'result_sha1'.
         */
        struct dir_struct dir;
-       const char *path = git_path(NOTES_MERGE_WORKTREE "/");
+       char *path = xstrdup(git_path(NOTES_MERGE_WORKTREE "/"));
        int path_len = strlen(path), i;
-       const char *msg = strstr(partial_commit->buffer, "\n\n");
+       char *msg = strstr(partial_commit->buffer, "\n\n");
+       struct strbuf sb_msg = STRBUF_INIT;
 
        if (o->verbosity >= 3)
                printf("Committing notes in notes merge worktree at %.*s\n",
@@ -722,7 +724,7 @@ int notes_merge_commit(struct notes_merge_options *o,
                /* write file as blob, and add to partial_tree */
                if (stat(ent->name, &st))
                        die_errno("Failed to stat '%s'", ent->name);
-               if (index_path(blob_sha1, ent->name, &st, 1))
+               if (index_path(blob_sha1, ent->name, &st, HASH_WRITE_OBJECT))
                        die("Failed to write blob object from '%s'", ent->name);
                if (add_note(partial_tree, obj_sha1, blob_sha1, NULL))
                        die("Failed to add resolved note '%s' to notes tree",
@@ -732,11 +734,13 @@ int notes_merge_commit(struct notes_merge_options *o,
                                sha1_to_hex(obj_sha1), sha1_to_hex(blob_sha1));
        }
 
-       create_notes_commit(partial_tree, partial_commit->parents, msg,
+       strbuf_attach(&sb_msg, msg, strlen(msg), strlen(msg) + 1);
+       create_notes_commit(partial_tree, partial_commit->parents, &sb_msg,
                            result_sha1);
        if (o->verbosity >= 4)
                printf("Finalized notes merge commit: %s\n",
                        sha1_to_hex(result_sha1));
+       free(path);
        return 0;
 }