git notes merge: Handle real, non-conflicting notes merges
[gitweb.git] / builtin / notes.c
index 32d8a249446d2b1dfa2105cce9900291a72fc643..c7761b1140b513fb8904342d8d408ad7951fb7a0 100644 (file)
@@ -765,6 +765,7 @@ static int merge(int argc, const char **argv, const char *prefix)
 {
        struct strbuf remote_ref = STRBUF_INIT, msg = STRBUF_INIT;
        unsigned char result_sha1[20];
+       struct notes_tree *t;
        struct notes_merge_options o;
        int verbosity = 0, result;
        struct option options[] = {
@@ -788,19 +789,23 @@ static int merge(int argc, const char **argv, const char *prefix)
        expand_notes_ref(&remote_ref);
        o.remote_ref = remote_ref.buf;
 
-       result = notes_merge(&o, result_sha1);
+       t = init_notes_check("merge");
 
        strbuf_addf(&msg, "notes: Merged notes from %s into %s",
                    remote_ref.buf, default_notes_ref());
-       if (result == 0) { /* Merge resulted (trivially) in result_sha1 */
+       o.commit_msg = msg.buf + 7; // skip "notes: " prefix
+
+       result = notes_merge(&o, t, result_sha1);
+
+       if (result >= 0) /* Merge resulted (trivially) in result_sha1 */
                /* Update default notes ref with new commit */
                update_ref(msg.buf, default_notes_ref(), result_sha1, NULL,
                           0, DIE_ON_ERR);
-       } else {
+       else
                /* TODO: */
-               die("'git notes merge' cannot yet handle non-trivial merges!");
-       }
+               die("'git notes merge' cannot yet handle conflicts!");
 
+       free_notes(t);
        strbuf_release(&remote_ref);
        strbuf_release(&msg);
        return 0;