[PATCH 04/11] revert: Separate cmdline argument handling from the functional code

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

 



Based-on-patch-by: Christian Couder <chriscool@xxxxxxxxxxxxx>
Signed-off-by: Ramkumar Ramachandra <artagnon@xxxxxxxxx>
---
 builtin/revert.c |   23 ++++++++++++++---------
 1 files changed, 14 insertions(+), 9 deletions(-)

diff --git a/builtin/revert.c b/builtin/revert.c
index 2b33220..9381541 100644
--- a/builtin/revert.c
+++ b/builtin/revert.c
@@ -578,18 +578,12 @@ static int read_and_refresh_cache(void)
 	return 0;
 }
 
-static int revert_or_cherry_pick(int argc, const char **argv)
+static int pick_commits(void)
 {
 	struct rev_info revs;
 	struct commit *commit;
-	const char *me;
 	int res;
 
-	git_config(git_default_config, NULL);
-	me = (cmd_opts.action == REVERT ? "revert" : "cherry-pick");
-	setenv(GIT_REFLOG_ACTION, me, 0);
-	parse_args(argc, argv);
-
 	if (cmd_opts.allow_ff) {
 		if (cmd_opts.signoff)
 			die(_("cherry-pick --ff cannot be used with --signoff"));
@@ -616,12 +610,23 @@ int cmd_revert(int argc, const char **argv, const char *prefix)
 {
 	if (isatty(0))
 		cmd_opts.edit = 1;
+
+	git_config(git_default_config, NULL);
+	memset(&cmd_opts, 0, sizeof(cmd_opts));
 	cmd_opts.action = REVERT;
-	return revert_or_cherry_pick(argc, argv);
+	setenv(GIT_REFLOG_ACTION, "revert", 0);
+	parse_args(argc, argv);
+
+	return pick_commits();
 }
 
 int cmd_cherry_pick(int argc, const char **argv, const char *prefix)
 {
+	git_config(git_default_config, NULL);
+	memset(&cmd_opts, 0, sizeof(cmd_opts));
 	cmd_opts.action = CHERRY_PICK;
-	return revert_or_cherry_pick(argc, argv);
+	setenv(GIT_REFLOG_ACTION, "cherry-pick", 0);
+	parse_args(argc, argv);
+
+	return pick_commits();
 }
-- 
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


[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]