Skip to content

Commit dffc860

Browse files
jrngitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent f80a872 commit dffc860

File tree

1 file changed

+24
-24
lines changed

1 file changed

+24
-24
lines changed

builtin/revert.c

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -971,40 +971,40 @@ static int pick_revisions(struct replay_opts *opts)
971971
if (opts->subcommand == REPLAY_REMOVE_STATE) {
972972
remove_sequencer_state(1);
973973
return 0;
974-
} else if (opts->subcommand == REPLAY_CONTINUE) {
974+
}
975+
if (opts->subcommand == REPLAY_CONTINUE) {
975976
if (!file_exists(git_path(SEQ_TODO_FILE)))
976-
goto error;
977+
return error(_("No %s in progress"), action_name(opts));
977978
read_populate_opts(&opts);
978979
read_populate_todo(&todo_list, opts);
979980

980981
/* Verify that the conflict has been resolved */
981982
if (!index_differs_from("HEAD", 0))
982983
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+
}
989986

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"));
10041004
}
1005+
save_head(sha1_to_hex(sha1));
1006+
save_opts(opts);
10051007
return pick_commits(todo_list, opts);
1006-
error:
1007-
return error(_("No %s in progress"), action_name(opts));
10081008
}
10091009

10101010
int cmd_revert(int argc, const char **argv, const char *prefix)

0 commit comments

Comments
 (0)