Signed-off-by: Ramkumar Ramachandra <artagnon@xxxxxxxxx> --- builtin/revert.c | 46 +++++++++++++++++++++++++++++++++++++++++++++- 1 files changed, 45 insertions(+), 1 deletions(-) diff --git a/builtin/revert.c b/builtin/revert.c index facae24..b90f3d0 100644 --- a/builtin/revert.c +++ b/builtin/revert.c @@ -39,6 +39,11 @@ static const char * const cherry_pick_usage[] = { static struct { enum { REVERT, CHERRY_PICK } action; + /* --abort, --skip, and --continue */ + int abort_oper; + int skip_oper; + int continue_oper; + /* Boolean options */ int edit; int no_replay; @@ -98,8 +103,12 @@ static void die_opt_incompatible(const char *me, const char *base_opt, static void parse_args(int argc, const char **argv) { const char * const * usage_str = revert_or_cherry_pick_usage(); + const char *me; int noop; struct option options[] = { + OPT_BOOLEAN(0, "abort", &cmd_opts.abort_oper, "abort the current operation"), + OPT_BOOLEAN(0, "skip", &cmd_opts.skip_oper, "skip the current commit"), + OPT_BOOLEAN(0, "continue", &cmd_opts.continue_oper, "continue the current operation"), OPT_BOOLEAN('n', "no-commit", &cmd_opts.no_commit, "don't automatically commit"), OPT_BOOLEAN('e', "edit", &cmd_opts.edit, "edit the commit message"), OPT_BOOLEAN('r', NULL, &noop, "no-op (backward compatibility)"), @@ -127,7 +136,42 @@ static void parse_args(int argc, const char **argv) cmd_opts.commit_argc = parse_options(argc, argv, NULL, options, usage_str, PARSE_OPT_KEEP_ARGV0 | PARSE_OPT_KEEP_UNKNOWN); - if (cmd_opts.commit_argc < 2) + + me = (cmd_opts.action == REVERT ? "revert" : "cherry-pick"); + + /* Check for incompatible command line arguments */ + if (cmd_opts.abort_oper || cmd_opts.skip_oper || cmd_opts.continue_oper) { + char *this_oper; + int opt_bitarray[] = {cmd_opts.no_commit, cmd_opts.edit, noop, + cmd_opts.signoff, cmd_opts.mainline, + (cmd_opts.strategy ? 1 : 0), + (cmd_opts.xopts ? 1 : 0), + cmd_opts.no_replay, cmd_opts.allow_ff}; + if (cmd_opts.abort_oper) { + this_oper = "--abort"; + die_opt_incompatible(me, this_oper, 1, + &cmd_opts.skip_oper, "--skip"); + die_opt_incompatible(me, this_oper, 1, + &cmd_opts.continue_oper, "--continue"); + } else if (cmd_opts.skip_oper) { + this_oper = "--skip"; + die_opt_incompatible(me, this_oper, 1, + &cmd_opts.abort_oper, "--abort"); + die_opt_incompatible(me, this_oper, 1, + &cmd_opts.continue_oper, "--continue"); + } else { + this_oper = "--continue"; + die_opt_incompatible(me, this_oper, 1, + &cmd_opts.abort_oper, "--abort"); + die_opt_incompatible(me, this_oper, 1, + &cmd_opts.skip_oper, "--skip"); + } + die_opt_incompatible(me, this_oper, 9, opt_bitarray, "--no-commit", + "--edit", "-r", "--signoff", "--mainline", + "--strategy", "--strategy-option", "-x", "--ff"); + } + + else if (cmd_opts.commit_argc < 2) usage_with_options(usage_str, options); if (cmd_opts.allow_ff) { -- 1.7.4.rc1.7.g2cf08.dirty -- 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