Merge branch 'rr/cherry-pick-fast-forward-reflog-message'
authorJunio C Hamano <gitster@pobox.com>
Thu, 27 Jun 2013 21:29:59 +0000 (14:29 -0700)
committerJunio C Hamano <gitster@pobox.com>
Thu, 27 Jun 2013 21:30:00 +0000 (14:30 -0700)
The reflog message created when "git cherry-pick" fast-forwarded
did not say anything but "cherry-pick", but it now says
"cherry-pick: fast-forward".

* rr/cherry-pick-fast-forward-reflog-message:
sequencer: write useful reflog message for fast-forward

1  2 
sequencer.c
diff --combined sequencer.c
index f7be7d8be66992567fe2140c6aecdd3cc6140d38,423c1f583d82675e8b184e4ac7081432c303dfe1..425207ad5f1068b17daa50199b6880ef6009db79
@@@ -270,15 -270,20 +270,20 @@@ static int error_dirty_index(struct rep
  }
  
  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 +479,7 @@@ static int do_pick_commit(struct commi
        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) {
                /*
        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
                      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);