From: Junio C Hamano Date: Fri, 7 Oct 2011 00:02:11 +0000 (-0700) Subject: Merge branch 'js/maint-no-cherry-pick-head-after-punted' into js/no-cherry-pick-head... X-Git-Tag: v1.7.8-rc0~39^2 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=278f7e6f6dc1b515f192daf836fe75d733435774;p=git.git Merge branch 'js/maint-no-cherry-pick-head-after-punted' into js/no-cherry-pick-head-after-punted * 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 --- 278f7e6f6dc1b515f192daf836fe75d733435774 diff --cc builtin/revert.c index ba27cf15e,e38fe0ce7..4eb4193d3 --- a/builtin/revert.c +++ b/builtin/revert.c @@@ -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; @@@ -588,17 -503,26 +588,26 @@@ free_commit_list(remotes); } + /* + * 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 (action == CHERRY_PICK && !no_commit && (res == 0 || res == 1)) - write_cherry_pick_head(); ++ 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);