This makes it possible to pass a range of commits like A..B to "git cherry-pick" and to "git revert" to process many commits instead of just one. But there is currently no way to continue cherry-picking or reverting if there is a problem with one commit. It's also not possible to abort the whole process. Some future work should provide the --continue and --abort options to do just that. Signed-off-by: Christian Couder <chriscool@xxxxxxxxxxxxx> --- builtin/revert.c | 43 +++++++++++++++++++++++++++++++++++++------ 1 files changed, 37 insertions(+), 6 deletions(-) diff --git a/builtin/revert.c b/builtin/revert.c index 70372dc..c281a80 100644 --- a/builtin/revert.c +++ b/builtin/revert.c @@ -53,7 +53,6 @@ static void parse_args(int argc, const char **argv) { const char * const * usage_str = action == REVERT ? revert_usage : cherry_pick_usage; - unsigned char sha1[20]; int noop; struct option options[] = { OPT_BOOLEAN('n', "no-commit", &no_commit, "don't automatically commit"), @@ -82,11 +81,6 @@ static void parse_args(int argc, const char **argv) usage_with_options(usage_str, options); commit_name = argv[0]; - if (get_sha1(commit_name, sha1)) - die ("Cannot find '%s'", commit_name); - commit = lookup_commit_reference(sha1); - if (!commit) - exit(1); } struct commit_message { @@ -522,6 +516,9 @@ static int do_pick_commit() static int revert_or_cherry_pick(int argc, const char **argv) { + const char *dotdot; + unsigned char sha1[20]; + git_config(git_default_config, NULL); me = action == REVERT ? "revert" : "cherry-pick"; setenv(GIT_REFLOG_ACTION, me, 0); @@ -545,6 +542,40 @@ static int revert_or_cherry_pick(int argc, const char **argv) if (read_cache() < 0) die("git %s: failed to read the index", me); + dotdot = strstr(commit_name, ".."); + if (dotdot) { + struct rev_info revs; + const char *argv[4]; + int argc = 0; + + argv[argc++] = NULL; + if (action != REVERT) + argv[argc++] = "--reverse"; + argv[argc++] = commit_name; + argv[argc++] = NULL; + + init_revisions(&revs, NULL); + setup_revisions(argc - 1, argv, &revs, NULL); + if (prepare_revision_walk(&revs)) + die("revision walk setup failed"); + + if (!revs.commits) + die("empty range passed"); + + while ( (commit = get_revision(&revs)) ) { + int res = do_pick_commit(); + if (res) + return res; + } + return 0; + } + + if (get_sha1(commit_name, sha1)) + die ("Cannot find '%s'", commit_name); + commit = lookup_commit_reference(sha1); + if (!commit) + exit(1); + return do_pick_commit(); } -- 1.7.1.346.g7c1d7.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