Skip to content

Commit dcb500d

Browse files
r1walzgitster
authored andcommitted
cherry-pick/revert: advise using --skip
The previous commit introduced a --skip flag for cherry-pick and revert. Update the advice messages, to tell users about this less cumbersome way of skipping commits. Also add tests to ensure everything is working fine. Signed-off-by: Rohit Ashiwal <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent de81ca3 commit dcb500d

File tree

3 files changed

+34
-8
lines changed

3 files changed

+34
-8
lines changed

builtin/commit.c

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,15 +60,18 @@ N_("The previous cherry-pick is now empty, possibly due to conflict resolution.\
6060
"\n");
6161

6262
static const char empty_cherry_pick_advice_single[] =
63-
N_("Otherwise, please use 'git reset'\n");
63+
N_("Otherwise, please use 'git cherry-pick --skip'\n");
6464

6565
static const char empty_cherry_pick_advice_multi[] =
66-
N_("If you wish to skip this commit, use:\n"
66+
N_("and then use:\n"
6767
"\n"
68-
" git reset\n"
68+
" git cherry-pick --continue\n"
6969
"\n"
70-
"Then \"git cherry-pick --continue\" will resume cherry-picking\n"
71-
"the remaining commits.\n");
70+
"to resume cherry-picking the remaining commits.\n"
71+
"If you wish to skip this commit, use:\n"
72+
"\n"
73+
" git cherry-pick --skip\n"
74+
"\n");
7275

7376
static const char *color_status_slots[] = {
7477
[WT_STATUS_HEADER] = "header",

sequencer.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2655,18 +2655,20 @@ static int create_seq_dir(struct repository *r)
26552655
enum replay_action action;
26562656
const char *in_progress_error = NULL;
26572657
const char *in_progress_advice = NULL;
2658+
unsigned int advise_skip = file_exists(git_path_revert_head(r)) ||
2659+
file_exists(git_path_cherry_pick_head(r));
26582660

26592661
if (!sequencer_get_last_command(r, &action)) {
26602662
switch (action) {
26612663
case REPLAY_REVERT:
26622664
in_progress_error = _("revert is already in progress");
26632665
in_progress_advice =
2664-
_("try \"git revert (--continue | --abort | --quit)\"");
2666+
_("try \"git revert (--continue | %s--abort | --quit)\"");
26652667
break;
26662668
case REPLAY_PICK:
26672669
in_progress_error = _("cherry-pick is already in progress");
26682670
in_progress_advice =
2669-
_("try \"git cherry-pick (--continue | --abort | --quit)\"");
2671+
_("try \"git cherry-pick (--continue | %s--abort | --quit)\"");
26702672
break;
26712673
default:
26722674
BUG("unexpected action in create_seq_dir");
@@ -2675,7 +2677,8 @@ static int create_seq_dir(struct repository *r)
26752677
if (in_progress_error) {
26762678
error("%s", in_progress_error);
26772679
if (advice_sequencer_in_use)
2678-
advise("%s", in_progress_advice);
2680+
advise(in_progress_advice,
2681+
advise_skip ? "--skip | " : "");
26792682
return -1;
26802683
}
26812684
if (mkdir(git_path_seq_dir(), 0777) < 0)

t/t3510-cherry-pick-sequence.sh

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,26 @@ test_expect_success 'check advice when we move HEAD by committing' '
172172
test_i18ncmp expect advice
173173
'
174174

175+
test_expect_success 'selectively advise --skip while launching another sequence' '
176+
pristine_detach initial &&
177+
cat >expect <<-EOF &&
178+
error: cherry-pick is already in progress
179+
hint: try "git cherry-pick (--continue | --skip | --abort | --quit)"
180+
fatal: cherry-pick failed
181+
EOF
182+
test_must_fail git cherry-pick picked..yetanotherpick &&
183+
test_must_fail git cherry-pick picked..yetanotherpick 2>advice &&
184+
test_i18ncmp expect advice &&
185+
cat >expect <<-EOF &&
186+
error: cherry-pick is already in progress
187+
hint: try "git cherry-pick (--continue | --abort | --quit)"
188+
fatal: cherry-pick failed
189+
EOF
190+
git reset --merge &&
191+
test_must_fail git cherry-pick picked..yetanotherpick 2>advice &&
192+
test_i18ncmp expect advice
193+
'
194+
175195
test_expect_success 'allow skipping commit but not abort for a new history' '
176196
pristine_detach initial &&
177197
cat >expect <<-EOF &&

0 commit comments

Comments
 (0)