revert: rearrange pick_revisions() for clarity

Deal completely with "cherry-pick --quit" and --continue at the beginning of pick_revisions(), leaving the rest of the function for the more interesting "git cherry-pick <commits>" case. No functional change intended. The impact is just to unindent the code a little. Signed-off-by: Jonathan Nieder <jrnieder@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Jonathan Nieder committed Nov 22, 2011 at 05:15 UTC dffc86002862753376e31a16a1c1c0306716fbe6
1 file changed +24 -24
builtin/revert.c
+24 -24
@@ -971,40 +971,40 @@ static int pick_revisions(struct replay_opts *opts)
971 if (opts->subcommand == REPLAY_REMOVE_STATE) {
972 remove_sequencer_state(1);
973 return 0;
974 - } else if (opts->subcommand == REPLAY_CONTINUE) {
974 + }
975 + if (opts->subcommand == REPLAY_CONTINUE) {
976 if (!file_exists(git_path(SEQ_TODO_FILE)))
976 - goto error;
977 + return error(_("No %s in progress"), action_name(opts));
978 read_populate_opts(&opts);
979 read_populate_todo(&todo_list, opts);
980
981 /* Verify that the conflict has been resolved */
982 if (!index_differs_from("HEAD", 0))
983 todo_list = todo_list->next;
983 - } else {
984 - /*
985 - * Start a new cherry-pick/ revert sequence; but
986 - * first, make sure that an existing one isn't in
987 - * progress
988 - */
984 + return pick_commits(todo_list, opts);
985 + }
986
990 - walk_revs_populate_todo(&todo_list, opts);
991 - if (create_seq_dir() < 0) {
992 - error(_("A cherry-pick or revert is in progress."));
993 - advise(_("Use --continue to continue the operation"));
994 - advise(_("or --quit to forget about it"));
995 - return -1;
996 - }
997 - if (get_sha1("HEAD", sha1)) {
998 - if (opts->action == REVERT)
999 - return error(_("Can't revert as initial commit"));
1000 - return error(_("Can't cherry-pick into empty head"));
1001 - }
1002 - save_head(sha1_to_hex(sha1));
1003 - save_opts(opts);
987 + /*
988 + * Start a new cherry-pick/ revert sequence; but
989 + * first, make sure that an existing one isn't in
990 + * progress
991 + */
992 +
993 + walk_revs_populate_todo(&todo_list, opts);
994 + if (create_seq_dir() < 0) {
995 + error(_("A cherry-pick or revert is in progress."));
996 + advise(_("Use --continue to continue the operation"));
997 + advise(_("or --quit to forget about it"));
998 + return -1;
999 + }
1000 + if (get_sha1("HEAD", sha1)) {
1001 + if (opts->action == REVERT)
1002 + return error(_("Can't revert as initial commit"));
1003 + return error(_("Can't cherry-pick into empty head"));
1004 }
1005 + save_head(sha1_to_hex(sha1));
1006 + save_opts(opts);
1007 return pick_commits(todo_list, opts);
1006 -error:
1007 - return error(_("No %s in progress"), action_name(opts));
1008 }
1009
1010 int cmd_revert(int argc, const char **argv, const char *prefix)