[PATCH 7/8] revert: Implement parsing --continue, --abort and --skip

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Introduce three new command-line options: --continue, --abort, and
--skip resembling the correspoding options in "rebase -i".  For now,
just parse the options into the replay_opts structure, making sure
that two of them are not specified together. They will actually be
implemented later in the series.

Signed-off-by: Ramkumar Ramachandra <artagnon@xxxxxxxxx>
---
 This patch is fairly straightforward.

 builtin/revert.c |   50 +++++++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 49 insertions(+), 1 deletions(-)

diff --git a/builtin/revert.c b/builtin/revert.c
index 13569c2..ccfc295 100644
--- a/builtin/revert.c
+++ b/builtin/revert.c
@@ -46,6 +46,11 @@ static const char * const cherry_pick_usage[] = {
 static struct replay_opts {
 	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;
@@ -112,6 +117,9 @@ static void parse_args(int argc, const char **argv, struct replay_opts *opts)
 	int noop;
 
 	struct option options[] = {
+		OPT_BOOLEAN(0, "abort", &(opts->abort_oper), "abort the current operation"),
+		OPT_BOOLEAN(0, "skip", &(opts->skip_oper), "skip the current commit"),
+		OPT_BOOLEAN(0, "continue", &(opts->continue_oper), "continue the current operation"),
 		OPT_BOOLEAN('n', "no-commit", &(opts->no_commit), "don't automatically commit"),
 		OPT_BOOLEAN('e', "edit", &(opts->edit), "edit the commit message"),
 		OPT_BOOLEAN('r', NULL, &noop, "no-op (backward compatibility)"),
@@ -145,7 +153,47 @@ static void parse_args(int argc, const char **argv, struct replay_opts *opts)
 	opts->xopts_nr = xopts_nr;
 	opts->xopts_alloc = xopts_alloc;
 
-	if (opts->commit_argc < 2)
+	/* Check for incompatible command line arguments */
+	if (opts->abort_oper || opts->skip_oper || opts->continue_oper) {
+		char *this_oper;
+		if (opts->abort_oper) {
+			this_oper = "--abort";
+			die_opt_incompatible(me, this_oper,
+					"--skip", opts->skip_oper,
+					NULL);
+			die_opt_incompatible(me, this_oper,
+					"--continue", opts->continue_oper,
+					NULL);
+		} else if (opts->skip_oper) {
+			this_oper = "--skip";
+			die_opt_incompatible(me, this_oper,
+					"--abort", opts->abort_oper,
+					NULL);
+			die_opt_incompatible(me, this_oper,
+					"--continue", opts->continue_oper,
+					NULL);
+		} else {
+			this_oper = "--continue";
+			die_opt_incompatible(me, this_oper,
+					"--abort", opts->abort_oper,
+					NULL);
+			die_opt_incompatible(me, this_oper,
+					"--skip", opts->skip_oper,
+					NULL);
+		}
+		die_opt_incompatible(me, this_oper,
+				"--no-commit", opts->no_commit,
+				"--edit", opts->edit, "-r", noop,
+				"--signoff", opts->signoff,
+				"--mainline", opts->mainline,
+				"--strategy", opts->strategy ? 1 : 0,
+				"--strategy-option", opts->xopts ? 1 : 0,
+				"-x", opts->no_replay,
+				"--ff", opts->allow_ff,
+				NULL);
+	}
+
+	else if (opts->commit_argc < 2)
 		usage_with_options(usage_str, options);
 
 	if (opts->allow_ff)
-- 
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


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]