Write a new function called process_continuation to prepare a todo_list to call pick_commits with; the job of pick_commits is simplified into performing the tasks listed in todo_list. This will be useful when continuation functionality like "--continue" is introduced later in the series. Helped-by: Jonathan Nieder <jrnider@xxxxxxxxx> Signed-off-by: Ramkumar Ramachandra <artagnon@xxxxxxxxx> --- builtin/revert.c | 33 ++++++++++++++++++++++----------- 1 files changed, 22 insertions(+), 11 deletions(-) diff --git a/builtin/revert.c b/builtin/revert.c index ca5756b..5c0b97e 100644 --- a/builtin/revert.c +++ b/builtin/revert.c @@ -675,21 +675,13 @@ static int cleanup_sequencer_data(void) return 0; } -static int pick_commits(struct replay_opts *opts) +static int pick_commits(struct commit_list *todo_list, struct replay_opts *opts) { - struct commit_list *todo_list = NULL; - unsigned char sha1[20]; struct commit_list *cur; int res; - read_and_refresh_cache(me, opts); setenv(GIT_REFLOG_ACTION, me, 0); - walk_revs_populate_todo(&todo_list, opts); - if (!get_sha1("HEAD", sha1)) - persist_head(sha1_to_hex(sha1)); - persist_todo(todo_list, opts); - for (cur = todo_list; cur; cur = cur->next) { persist_todo(cur, opts); res = do_pick_commit(cur->item, opts); @@ -702,6 +694,21 @@ static int pick_commits(struct replay_opts *opts) return cleanup_sequencer_data(); } +static int process_continuation(struct replay_opts *opts) +{ + struct commit_list *todo_list = NULL; + unsigned char sha1[20]; + + read_and_refresh_cache(me, opts); + + walk_revs_populate_todo(&todo_list, opts); + if (!get_sha1("HEAD", sha1)) + persist_head(sha1_to_hex(sha1)); + persist_todo(todo_list, opts); + + return pick_commits(todo_list, opts); +} + int cmd_revert(int argc, const char **argv, const char *prefix) { int res; @@ -714,7 +721,11 @@ int cmd_revert(int argc, const char **argv, const char *prefix) git_config(git_default_config, NULL); me = "revert"; parse_args(argc, argv, &opts); - res = pick_commits(&opts); + + /* Decide what to do depending on the arguments; a fresh + cherry-pick should be handled differently from an existing + one that is being continued */ + res = process_continuation(&opts); if (res > 0) /* Exit status from conflict */ return res; @@ -734,7 +745,7 @@ int cmd_cherry_pick(int argc, const char **argv, const char *prefix) git_config(git_default_config, NULL); me = "cherry-pick"; parse_args(argc, argv, &opts); - res = pick_commits(&opts); + res = process_continuation(&opts); if (res > 0) return res; if (res < 0) -- 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