summaryrefslogtreecommitdiff
path: root/builtin/revert.c
diff options
context:
space:
mode:
Diffstat (limited to 'builtin/revert.c')
-rw-r--r--builtin/revert.c27
1 files changed, 25 insertions, 2 deletions
diff --git a/builtin/revert.c b/builtin/revert.c
index bb6e9e8..e716a1b 100644
--- a/builtin/revert.c
+++ b/builtin/revert.c
@@ -231,6 +231,22 @@ static void set_author_ident_env(const char *message)
sha1_to_hex(commit->object.sha1));
}
+static void write_cherry_pick_head(void)
+{
+ int fd;
+ struct strbuf buf = STRBUF_INIT;
+
+ strbuf_addf(&buf, "%s\n", sha1_to_hex(commit->object.sha1));
+
+ fd = open(git_path("CHERRY_PICK_HEAD"), O_WRONLY | O_CREAT, 0666);
+ if (fd < 0)
+ die_errno("Could not open '%s' for writing",
+ git_path("CHERRY_PICK_HEAD"));
+ if (write_in_full(fd, buf.buf, buf.len) != buf.len || close(fd))
+ die_errno("Could not write to '%s'", git_path("CHERRY_PICK_HEAD"));
+ strbuf_release(&buf);
+}
+
static void advise(const char *advice, ...)
{
va_list params;
@@ -246,6 +262,12 @@ static void print_advice(void)
if (msg) {
fprintf(stderr, "%s\n", msg);
+ /*
+ * A conflict has occured but the porcelain
+ * (typically rebase --interactive) wants to take care
+ * of the commit itself so remove CHERRY_PICK_HEAD
+ */
+ unlink(git_path("CHERRY_PICK_HEAD"));
return;
}
@@ -253,8 +275,7 @@ static void print_advice(void)
advise("with 'git add <paths>' or 'git rm <paths>'");
if (action == CHERRY_PICK)
- advise("and commit the result with 'git commit -c %s'",
- find_unique_abbrev(commit->object.sha1, DEFAULT_ABBREV));
+ advise("and commit the result with 'git commit -c CHERRY_PICK_HEAD'");
}
static void write_message(struct strbuf *msgbuf, const char *filename)
@@ -489,6 +510,8 @@ static int do_pick_commit(void)
strbuf_addstr(&msgbuf, sha1_to_hex(commit->object.sha1));
strbuf_addstr(&msgbuf, ")\n");
}
+ if (!no_commit)
+ write_cherry_pick_head();
}
if (!strategy || !strcmp(strategy, "recursive") || action == REVERT) {