summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 80e1f79)
raw | patch | inline | side by side (parent: 80e1f79)
author | Ramkumar Ramachandra <artagnon@gmail.com> | |
Thu, 4 Aug 2011 10:39:06 +0000 (16:09 +0530) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Thu, 4 Aug 2011 22:40:43 +0000 (15:40 -0700) |
Currently, revert_or_cherry_pick sets up a default git config, parses
command-line arguments, before preparing to pick commits. This makes
for a bad API as the central worry of callers is to assert whether or
not a conflict occured while cherry picking. The current API is like:
if (revert_or_cherry_pick(argc, argv, opts) < 0)
print "Something failed, we're not sure what"
Simplify and rename revert_or_cherry_pick to pick_commits so that it
only has the responsibility of setting up the revision walker and
picking commits in a loop. Transfer the remaining work to its
callers. Now, the API is simplified as:
if (parse_args(argc, argv, opts) < 0)
print "Can't parse arguments"
if (pick_commits(opts) < 0)
print "Error encountered in picking machinery"
Later in the series, pick_commits will also serve as the starting
point for continuing a cherry-pick or revert.
Inspired-by: Christian Couder <chriscool@tuxfamily.org>
Helped-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com>
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
command-line arguments, before preparing to pick commits. This makes
for a bad API as the central worry of callers is to assert whether or
not a conflict occured while cherry picking. The current API is like:
if (revert_or_cherry_pick(argc, argv, opts) < 0)
print "Something failed, we're not sure what"
Simplify and rename revert_or_cherry_pick to pick_commits so that it
only has the responsibility of setting up the revision walker and
picking commits in a loop. Transfer the remaining work to its
callers. Now, the API is simplified as:
if (parse_args(argc, argv, opts) < 0)
print "Can't parse arguments"
if (pick_commits(opts) < 0)
print "Error encountered in picking machinery"
Later in the series, pick_commits will also serve as the starting
point for continuing a cherry-pick or revert.
Inspired-by: Christian Couder <chriscool@tuxfamily.org>
Helped-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com>
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/revert.c | patch | blob | history |
diff --git a/builtin/revert.c b/builtin/revert.c
index 50f72debe03b75c9d73617f18f146a1d9c374ebd..90fe2efe94874638e7a7998efa9b4e75d6d28943 100644 (file)
--- a/builtin/revert.c
+++ b/builtin/revert.c
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);
setenv(GIT_REFLOG_ACTION, action_name(opts), 0);
- parse_args(argc, argv, opts);
-
if (opts->allow_ff) {
if (opts->signoff)
die(_("cherry-pick --ff cannot be used with --signoff"));
if (isatty(0))
opts.edit = 1;
opts.action = REVERT;
- return revert_or_cherry_pick(argc, argv, &opts);
+ git_config(git_default_config, NULL);
+ parse_args(argc, argv, &opts);
+ return pick_commits(&opts);
}
int cmd_cherry_pick(int argc, const char **argv, const char *prefix)
memset(&opts, 0, sizeof(opts));
opts.action = CHERRY_PICK;
- return revert_or_cherry_pick(argc, argv, &opts);
+ git_config(git_default_config, NULL);
+ parse_args(argc, argv, &opts);
+ return pick_commits(&opts);
}