Skip to content

Commit af77c0b

Browse files
committed
Merge branch 'jk/commit-how-to-abort-cherry-pick'
* jk/commit-how-to-abort-cherry-pick: commit: tweak empty cherry pick advice for sequencer
2 parents 652d2bf + c17592a commit af77c0b

File tree

1 file changed

+22
-3
lines changed

1 file changed

+22
-3
lines changed

builtin/commit.c

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,18 @@ N_("The previous cherry-pick is now empty, possibly due to conflict resolution.\
6363
"If you wish to commit it anyway, use:\n"
6464
"\n"
6565
" git commit --allow-empty\n"
66+
"\n");
67+
68+
static const char empty_cherry_pick_advice_single[] =
69+
N_("Otherwise, please use 'git reset'\n");
70+
71+
static const char empty_cherry_pick_advice_multi[] =
72+
N_("If you wish to skip this commit, use:\n"
6673
"\n"
67-
"Otherwise, please use 'git reset'\n");
74+
" git reset\n"
75+
"\n"
76+
"Then \"git cherry-pick --continue\" will resume cherry-picking\n"
77+
"the remaining commits.\n");
6878

6979
static const char *use_message_buffer;
7080
static const char commit_editmsg[] = "COMMIT_EDITMSG";
@@ -107,6 +117,7 @@ static enum {
107117
static const char *cleanup_arg;
108118

109119
static enum commit_whence whence;
120+
static int sequencer_in_use;
110121
static int use_editor = 1, include_status = 1;
111122
static int show_ignored_in_status, have_option_m;
112123
static const char *only_include_assumed;
@@ -141,8 +152,11 @@ static void determine_whence(struct wt_status *s)
141152
{
142153
if (file_exists(git_path("MERGE_HEAD")))
143154
whence = FROM_MERGE;
144-
else if (file_exists(git_path("CHERRY_PICK_HEAD")))
155+
else if (file_exists(git_path("CHERRY_PICK_HEAD"))) {
145156
whence = FROM_CHERRY_PICK;
157+
if (file_exists(git_path("sequencer")))
158+
sequencer_in_use = 1;
159+
}
146160
else
147161
whence = FROM_COMMIT;
148162
if (s)
@@ -810,8 +824,13 @@ static int prepare_to_commit(const char *index_file, const char *prefix,
810824
run_status(stdout, index_file, prefix, 0, s);
811825
if (amend)
812826
fputs(_(empty_amend_advice), stderr);
813-
else if (whence == FROM_CHERRY_PICK)
827+
else if (whence == FROM_CHERRY_PICK) {
814828
fputs(_(empty_cherry_pick_advice), stderr);
829+
if (!sequencer_in_use)
830+
fputs(_(empty_cherry_pick_advice_single), stderr);
831+
else
832+
fputs(_(empty_cherry_pick_advice_multi), stderr);
833+
}
815834
return 0;
816835
}
817836

0 commit comments

Comments
 (0)