To abort, perform a "rerere clear" and "reset --hard" to the ref specified by the HEAD file introduced earlier in the series. Signed-off-by: Ramkumar Ramachandra <artagnon@xxxxxxxxx> --- builtin/revert.c | 46 ++++++++++++++++++++++++++++++++++++++++++---- 1 files changed, 42 insertions(+), 4 deletions(-) diff --git a/builtin/revert.c b/builtin/revert.c index f33d40a..be63aee 100644 --- a/builtin/revert.c +++ b/builtin/revert.c @@ -208,8 +208,6 @@ static void parse_args(int argc, const char **argv, struct replay_opts *opts) NULL); /* Remove these when the options are actually implemented */ - if (opts->abort_oper) - die("--abort is not implemented yet"); if (opts->skip_oper) die("--skip is not implemented yet"); if (opts->continue_oper) @@ -732,6 +730,46 @@ static int pick_commits(struct replay_opts *opts) return 0; } +static int process_continuation(struct replay_opts *opts) +{ + if (opts->abort_oper) { + char head[DEFAULT_ABBREV]; + unsigned char sha1[20]; + int fd; + rerere_clear(0); + + if (!file_exists(HEAD_FILE)) + goto error; + fd = open(HEAD_FILE, O_RDONLY, 0666); + if (fd < 0) + return error(_("Could not open '%s' for reading: %s"), + HEAD_FILE, strerror(errno)); + if (xread(fd, head, DEFAULT_ABBREV) < DEFAULT_ABBREV) { + close(fd); + return error(_("Corrupt '%s': %s"), HEAD_FILE, strerror(errno)); + } + close(fd); + + if (get_sha1(head, sha1)) + return error(_("Failed to resolve '%s' as a valid ref."), head); + update_ref(NULL, "HEAD", sha1, NULL, 0, MSG_ON_ERR); + } + else if (opts->skip_oper) { + if (!file_exists(TODO_FILE)) + goto error; + return 0; + } + else if (opts->continue_oper) { + if (!file_exists(TODO_FILE)) + goto error; + return 0; + } + + return pick_commits(opts); +error: + return error(_("No %s in progress"), me); +} + int cmd_revert(int argc, const char **argv, const char *prefix) { int res; @@ -744,7 +782,7 @@ int cmd_revert(int argc, const char **argv, const char *prefix) git_config(git_default_config, NULL); me = "revert"; parse_args(argc, argv, &opts); - res = pick_commits(&opts); + res = process_continuation(&opts); if (res > 0) /* Exit status from conflict */ return res; @@ -764,7 +802,7 @@ int cmd_cherry_pick(int argc, const char **argv, const char *prefix) git_config(git_default_config, NULL); me = "cherry-pick"; parse_args(argc, argv, &opts); - res = pick_commits(&opts); + res = process_continuation(&opts); if (res > 0) return res; if (res < 0) -- 1.7.5.GIT -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html