]> git.ipfire.org Git - thirdparty/git.git/commitdiff
Merge branch 'js/maint-no-cherry-pick-head-after-punted' into js/no-cherry-pick-head...
authorJunio C Hamano <gitster@pobox.com>
Fri, 7 Oct 2011 00:02:11 +0000 (17:02 -0700)
committerJunio C Hamano <gitster@pobox.com>
Fri, 7 Oct 2011 00:02:11 +0000 (17:02 -0700)
* js/maint-no-cherry-pick-head-after-punted:
  cherry-pick: do not give irrelevant advice when cherry-pick punted
  revert.c: defer writing CHERRY_PICK_HEAD till it is safe to do so

Conflicts:
builtin/revert.c

1  2 
builtin/revert.c

index ba27cf15ee5478981a0a9a53493f41b67fcf9440,e38fe0ce7ad2702c4a6edae262635c4f638ffcb6..4eb4193d34a3c5328fba50e70d38654c386c7906
@@@ -304,7 -214,16 +304,7 @@@ static void write_cherry_pick_head(stru
        strbuf_release(&buf);
  }
  
- static void print_advice(void)
 -static void advise(const char *advice, ...)
 -{
 -      va_list params;
 -
 -      va_start(params, advice);
 -      vreportf("hint: ", advice, params);
 -      va_end(params);
 -}
 -
+ static void print_advice(int show_hint)
  {
        char *msg = getenv("GIT_CHERRY_PICK_HELP");
  
@@@ -566,13 -483,11 +568,11 @@@ static int do_pick_commit(struct commi
                        strbuf_addstr(&msgbuf, sha1_to_hex(commit->object.sha1));
                        strbuf_addstr(&msgbuf, ")\n");
                }
-               if (!opts->no_commit)
-                       write_cherry_pick_head(commit);
        }
  
 -      if (!strategy || !strcmp(strategy, "recursive") || action == REVERT) {
 +      if (!opts->strategy || !strcmp(opts->strategy, "recursive") || opts->action == REVERT) {
                res = do_recursive_merge(base, next, base_label, next_label,
 -                                       head, &msgbuf);
 +                                       head, &msgbuf, opts);
                write_message(&msgbuf, defmsg);
        } else {
                struct commit_list *common = NULL;
                free_commit_list(remotes);
        }
  
 -      if (action == CHERRY_PICK && !no_commit && (res == 0 || res == 1))
 -              write_cherry_pick_head();
+       /*
+        * If the merge was clean or if it failed due to conflict, we write
+        * CHERRY_PICK_HEAD for the subsequent invocation of commit to use.
+        * However, if the merge did not even start, then we don't want to
+        * write it at all.
+        */
++      if (opts->action == CHERRY_PICK && !opts->no_commit && (res == 0 || res == 1))
++              write_cherry_pick_head(commit);
        if (res) {
 -              error(action == REVERT
 +              error(opts->action == REVERT
                      ? _("could not revert %s... %s")
                      : _("could not apply %s... %s"),
                      find_unique_abbrev(commit->object.sha1, DEFAULT_ABBREV),
                      msg.subject);
-               print_advice();
+               print_advice(res == 1);
 -              rerere(allow_rerere_auto);
 +              rerere(opts->allow_rerere_auto);
        } else {
 -              if (!no_commit)
 -                      res = run_git_commit(defmsg);
 +              if (!opts->no_commit)
 +                      res = run_git_commit(defmsg, opts);
        }
  
        free_message(&msg);