author | Junio C Hamano <gitster@pobox.com> | |
Fri, 7 Oct 2011 00:02:11 +0000 (17:02 -0700) | ||
committer | Junio 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
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 | patch | | diff1 | | diff2 | | blob | history |
diff --cc builtin/revert.c
index ba27cf15ee5478981a0a9a53493f41b67fcf9440,e38fe0ce7ad2702c4a6edae262635c4f638ffcb6..4eb4193d34a3c5328fba50e70d38654c386c7906
--- 1/builtin/revert.c
--- 2/builtin/revert.c
+++ b/builtin/revert.c
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");
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);