Merge branch 'sb/mailmap-merijn-brand'
[gitweb.git] / sequencer.c
index ab6f8a722d1dfa8f9633d8c046aad26ef4d0404e..425207ad5f1068b17daa50199b6880ef6009db79 100644 (file)
@@ -270,15 +270,20 @@ static int error_dirty_index(struct replay_opts *opts)
 }
 
 static int fast_forward_to(const unsigned char *to, const unsigned char *from,
-                          int unborn)
+                       int unborn, struct replay_opts *opts)
 {
        struct ref_lock *ref_lock;
+       struct strbuf sb = STRBUF_INIT;
+       int ret;
 
        read_cache();
        if (checkout_fast_forward(from, to, 1))
                exit(1); /* the callee should have complained already */
        ref_lock = lock_any_ref_for_update("HEAD", unborn ? null_sha1 : from, 0);
-       return write_ref_sha1(ref_lock, to, "cherry-pick");
+       strbuf_addf(&sb, "%s: fast-forward", action_name(opts));
+       ret = write_ref_sha1(ref_lock, to, sb.buf);
+       strbuf_release(&sb);
+       return ret;
 }
 
 static int do_recursive_merge(struct commit *base, struct commit *next,
@@ -474,7 +479,7 @@ static int do_pick_commit(struct commit *commit, struct replay_opts *opts)
        struct commit_message msg = { NULL, NULL, NULL, NULL, NULL };
        char *defmsg = NULL;
        struct strbuf msgbuf = STRBUF_INIT;
-       int res, unborn = 0;
+       int res, unborn = 0, allow;
 
        if (opts->no_commit) {
                /*
@@ -523,7 +528,7 @@ static int do_pick_commit(struct commit *commit, struct replay_opts *opts)
        if (opts->allow_ff &&
            ((parent && !hashcmp(parent->object.sha1, head)) ||
             (!parent && unborn)))
-            return fast_forward_to(commit->object.sha1, head, unborn);
+               return fast_forward_to(commit->object.sha1, head, unborn, opts);
 
        if (parent && parse_commit(parent) < 0)
                /* TRANSLATORS: The first %s will be "revert" or
@@ -624,14 +629,18 @@ static int do_pick_commit(struct commit *commit, struct replay_opts *opts)
                      msg.subject);
                print_advice(res == 1, opts);
                rerere(opts->allow_rerere_auto);
-       } else {
-               int allow = allow_empty(opts, commit);
-               if (allow < 0)
-                       return allow;
-               if (!opts->no_commit)
-                       res = run_git_commit(defmsg, opts, allow);
+               goto leave;
+       }
+
+       allow = allow_empty(opts, commit);
+       if (allow < 0) {
+               res = allow;
+               goto leave;
        }
+       if (!opts->no_commit)
+               res = run_git_commit(defmsg, opts, allow);
 
+leave:
        free_message(&msg);
        free(defmsg);