[PATCH 06/10] revert: Separate cmdline parsing from functional code
From: Ramkumar Ramachandra <hidden>
Date: 2016-06-15 22:51:19
Subsystem:
the rest · Maintainer:
Linus Torvalds
Make cmd_cherry_pick and cmd_revert call parse_args and parse all the command-line arguments into an opts structure before sending it off to a simplified pick_commits function. pick_commits, in turn will set up the revision walker and call do_pick_commit in a loop- later in the series, it will serve as the starting point for continuation. Based-on-patch-by: Christian Couder [off-list ref] Helped-by: Jonathan Nieder [off-list ref] Signed-off-by: Ramkumar Ramachandra <redacted> --- builtin/revert.c | 17 +++++++++-------- 1 files changed, 9 insertions(+), 8 deletions(-)
diff --git a/builtin/revert.c b/builtin/revert.c
index cc2fa73..2e5f260 100644
--- a/builtin/revert.c
+++ b/builtin/revert.c@@ -550,17 +550,12 @@ static void read_and_refresh_cache(const char *me, struct replay_opts *opts) rollback_lock_file(&index_lock); } -static int revert_or_cherry_pick(int argc, const char **argv, - struct replay_opts *opts) +static int pick_commits(struct replay_opts *opts) { struct rev_info revs; struct commit *commit; - git_config(git_default_config, NULL); - me = opts->action == REVERT ? "revert" : "cherry-pick"; setenv(GIT_REFLOG_ACTION, me, 0); - parse_args(argc, argv, opts); - if (opts->allow_ff) { if (opts->signoff) die(_("cherry-pick --ff cannot be used with --signoff"));
@@ -594,7 +589,10 @@ int cmd_revert(int argc, const char **argv, const char *prefix) if (isatty(0)) opts.edit = 1; opts.action = REVERT; - res = revert_or_cherry_pick(argc, argv, &opts); + git_config(git_default_config, NULL); + me = "revert"; + parse_args(argc, argv, &opts); + res = pick_commits(&opts); if (res > 0) /* Exit status from conflict */ return res;
@@ -611,7 +609,10 @@ int cmd_cherry_pick(int argc, const char **argv, const char *prefix) memset(&opts, 0, sizeof(struct replay_opts)); opts.action = CHERRY_PICK; - res = revert_or_cherry_pick(argc, argv, &opts); + git_config(git_default_config, NULL); + me = "cherry-pick"; + parse_args(argc, argv, &opts); + res = pick_commits(&opts); if (res > 0) return res; if (res < 0)
--
1.7.5.GIT