Skip to content

Commit b8c7469

Browse files
jrngitster
authored andcommitted
revert: improve error message for cherry-pick during cherry-pick
In the spirit of v1.6.3.3~3^2 (refuse to merge during a merge, 2009-07-01), "git cherry-pick" refuses to start a new cherry-pick when in the middle of an existing conflicted cherry-pick in the following sequence: 1. git cherry-pick HEAD..origin 2. resolve conflicts 3. git cherry-pick HEAD..origin (instead of "git cherry-pick --continue", by mistake) Good. However, the error message on attempting step 3 is more convoluted than necessary: $ git cherry-pick HEAD..origin error: .git/sequencer already exists. error: A cherry-pick or revert is in progress. hint: Use --continue to continue the operation hint: or --quit to forget about it fatal: cherry-pick failed Clarify by removing the redundant first "error:" message, simplifying the advice, and using lower-case and no full stops to be consistent with other commands that prefix their messages with "error:", so it becomes error: a cherry-pick or revert is already in progress hint: try "git cherry-pick (--continue | --quit)" fatal: cherry-pick failed The "fatal: cherry-pick failed" line seems unnecessary, too, but that can be fixed some other day. Signed-off-by: Jonathan Nieder <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent dffc860 commit b8c7469

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

builtin/revert.c

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -846,8 +846,11 @@ static int create_seq_dir(void)
846846
{
847847
const char *seq_dir = git_path(SEQ_DIR);
848848

849-
if (file_exists(seq_dir))
850-
return error(_("%s already exists."), seq_dir);
849+
if (file_exists(seq_dir)) {
850+
error(_("a cherry-pick or revert is already in progress"));
851+
advise(_("try \"git cherry-pick (--continue | --quit)\""));
852+
return -1;
853+
}
851854
else if (mkdir(seq_dir, 0777) < 0)
852855
die_errno(_("Could not create sequencer directory %s"), seq_dir);
853856
return 0;
@@ -991,12 +994,8 @@ static int pick_revisions(struct replay_opts *opts)
991994
*/
992995

993996
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"));
997+
if (create_seq_dir() < 0)
998998
return -1;
999-
}
1000999
if (get_sha1("HEAD", sha1)) {
10011000
if (opts->action == REVERT)
10021001
return error(_("Can't revert as initial commit"));

0 commit comments

Comments
 (0)