Skip to content

Commit 1f62d2e

Browse files
committed
Revert "Merge branch 'zh/cherry-pick-help-is-only-for-sequencer' into next"
This reverts commit 9ea14ed, reversing changes made to b95a81a, to solve it differently with the zh/cherry-pick-advice topic.
1 parent d937d09 commit 1f62d2e

File tree

6 files changed

+32
-60
lines changed

6 files changed

+32
-60
lines changed

builtin/rebase.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,6 @@ static struct replay_opts get_replay_opts(const struct rebase_options *opts)
152152
oidcpy(&replay.squash_onto, opts->squash_onto);
153153
replay.have_squash_onto = 1;
154154
}
155-
replay.delete_cherry_pick_head = 1;
156155

157156
return replay;
158157
}

builtin/revert.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,8 +127,6 @@ static int run_sequencer(int argc, const char **argv, struct replay_opts *opts)
127127
OPT_BOOL(0, "allow-empty", &opts->allow_empty, N_("preserve initially empty commits")),
128128
OPT_BOOL(0, "allow-empty-message", &opts->allow_empty_message, N_("allow commits with empty messages")),
129129
OPT_BOOL(0, "keep-redundant-commits", &opts->keep_redundant_commits, N_("keep redundant, empty commits")),
130-
OPT_BOOL_F(0, "delete-cherry-pick-head", &opts->delete_cherry_pick_head,
131-
N_("delete CHERRY_PICK_HEAD when conflict occurs"), PARSE_OPT_HIDDEN),
132130
OPT_END(),
133131
};
134132
options = parse_options_concat(options, cp_extra);

git-rebase--preserve-merges.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -444,7 +444,7 @@ pick_one_preserving_merges () {
444444
output eval git cherry-pick $allow_rerere_autoupdate \
445445
$allow_empty_message \
446446
${gpg_sign_opt:+$(git rev-parse --sq-quote "$gpg_sign_opt")} \
447-
"$strategy_args" --delete-cherry-pick-head "$@" ||
447+
"$strategy_args" "$@" ||
448448
die_with_patch $sha1 "$(eval_gettext "Could not pick \$sha1")"
449449
;;
450450
esac

sequencer.c

Lines changed: 16 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -397,22 +397,25 @@ static void free_message(struct commit *commit, struct commit_message *msg)
397397
unuse_commit_buffer(commit, msg->message);
398398
}
399399

400-
static void print_advice(struct replay_opts *opts, int show_hint)
400+
static void print_advice(struct repository *r, int show_hint,
401+
struct replay_opts *opts)
401402
{
402403
char *msg = getenv("GIT_CHERRY_PICK_HELP");
403404

404405
if (msg) {
405-
advise("%s\n", msg);
406-
} else if (show_hint) {
407-
if (opts->action == REPLAY_PICK) {
408-
advise(_("Resolve all conflicts manually, mark them as resolved with\n"
409-
"\"git add/rm <conflicted_files>\", then run\n"
410-
"\"git cherry-pick --continue\".\n"
411-
"You can instead skip this commit: run \"git cherry-pick --skip\".\n"
412-
"To abort and get back to the state before \"git cherry-pick\",\n"
413-
"run \"git cherry-pick --abort\"."));
414-
415-
} else if (opts->no_commit)
406+
fprintf(stderr, "%s\n", msg);
407+
/*
408+
* A conflict has occurred but the porcelain
409+
* (typically rebase --interactive) wants to take care
410+
* of the commit itself so remove CHERRY_PICK_HEAD
411+
*/
412+
refs_delete_ref(get_main_ref_store(r), "", "CHERRY_PICK_HEAD",
413+
NULL, 0);
414+
return;
415+
}
416+
417+
if (show_hint) {
418+
if (opts->no_commit)
416419
advise(_("after resolving the conflicts, mark the corrected paths\n"
417420
"with 'git add <paths>' or 'git rm <paths>'"));
418421
else
@@ -2262,16 +2265,7 @@ static int do_pick_commit(struct repository *r,
22622265
? _("could not revert %s... %s")
22632266
: _("could not apply %s... %s"),
22642267
short_commit_name(commit), msg.subject);
2265-
print_advice(opts, res == 1);
2266-
if (opts->delete_cherry_pick_head) {
2267-
/*
2268-
* A conflict has occurred but the porcelain
2269-
* (typically rebase --interactive) wants to take care
2270-
* of the commit itself so remove CHERRY_PICK_HEAD
2271-
*/
2272-
refs_delete_ref(get_main_ref_store(r), "", "CHERRY_PICK_HEAD",
2273-
NULL, 0);
2274-
}
2268+
print_advice(r, res == 1, opts);
22752269
repo_rerere(r, opts->allow_rerere_auto);
22762270
goto leave;
22772271
}

sequencer.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ struct replay_opts {
4949
int reschedule_failed_exec;
5050
int committer_date_is_author_date;
5151
int ignore_date;
52-
int delete_cherry_pick_head;
5352

5453
int mainline;
5554

t/t3507-cherry-pick-conflict.sh

Lines changed: 15 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,9 @@ test_expect_success 'advice from failed cherry-pick' "
5353
picked=\$(git rev-parse --short picked) &&
5454
cat <<-EOF >expected &&
5555
error: could not apply \$picked... picked
56-
hint: Resolve all conflicts manually, mark them as resolved with
57-
hint: \"git add/rm <conflicted_files>\", then run
58-
hint: \"git cherry-pick --continue\".
59-
hint: You can instead skip this commit: run \"git cherry-pick --skip\".
60-
hint: To abort and get back to the state before \"git cherry-pick\",
61-
hint: run \"git cherry-pick --abort\".
56+
hint: after resolving the conflicts, mark the corrected paths
57+
hint: with 'git add <paths>' or 'git rm <paths>'
58+
hint: and commit the result with 'git commit'
6259
EOF
6360
test_must_fail git cherry-pick picked 2>actual &&
6461
@@ -71,45 +68,20 @@ test_expect_success 'advice from failed cherry-pick --no-commit' "
7168
picked=\$(git rev-parse --short picked) &&
7269
cat <<-EOF >expected &&
7370
error: could not apply \$picked... picked
74-
hint: Resolve all conflicts manually, mark them as resolved with
75-
hint: \"git add/rm <conflicted_files>\", then run
76-
hint: \"git cherry-pick --continue\".
77-
hint: You can instead skip this commit: run \"git cherry-pick --skip\".
78-
hint: To abort and get back to the state before \"git cherry-pick\",
79-
hint: run \"git cherry-pick --abort\".
71+
hint: after resolving the conflicts, mark the corrected paths
72+
hint: with 'git add <paths>' or 'git rm <paths>'
8073
EOF
8174
test_must_fail git cherry-pick --no-commit picked 2>actual &&
8275
8376
test_cmp expected actual
8477
"
8578

86-
test_expect_success 'advice from failed cherry-pick with GIT_CHERRY_PICK_HELP' "
87-
pristine_detach initial &&
88-
(
89-
picked=\$(git rev-parse --short picked) &&
90-
cat <<-EOF >expected &&
91-
error: could not apply \$picked... picked
92-
hint: and then do something else
93-
EOF
94-
GIT_CHERRY_PICK_HELP='and then do something else' &&
95-
export GIT_CHERRY_PICK_HELP &&
96-
test_must_fail git cherry-pick picked 2>actual &&
97-
test_cmp expected actual
98-
)
99-
"
100-
10179
test_expect_success 'failed cherry-pick sets CHERRY_PICK_HEAD' '
10280
pristine_detach initial &&
10381
test_must_fail git cherry-pick picked &&
10482
test_cmp_rev picked CHERRY_PICK_HEAD
10583
'
10684

107-
test_expect_success 'failed cherry-pick with --delete-cherry-pick-head does not set CHERRY_PICK_HEAD' '
108-
pristine_detach initial &&
109-
test_must_fail git cherry-pick --delete-cherry-pick-head picked &&
110-
test_must_fail git rev-parse --verify CHERRY_PICK_HEAD
111-
'
112-
11385
test_expect_success 'successful cherry-pick does not set CHERRY_PICK_HEAD' '
11486
pristine_detach initial &&
11587
git cherry-pick base &&
@@ -137,6 +109,16 @@ test_expect_success \
137109
test_must_fail git rev-parse --verify CHERRY_PICK_HEAD
138110
'
139111

112+
test_expect_success 'GIT_CHERRY_PICK_HELP suppresses CHERRY_PICK_HEAD' '
113+
pristine_detach initial &&
114+
(
115+
GIT_CHERRY_PICK_HELP="and then do something else" &&
116+
export GIT_CHERRY_PICK_HELP &&
117+
test_must_fail git cherry-pick picked
118+
) &&
119+
test_must_fail git rev-parse --verify CHERRY_PICK_HEAD
120+
'
121+
140122
test_expect_success 'git reset clears CHERRY_PICK_HEAD' '
141123
pristine_detach initial &&
142124

0 commit comments

Comments
 (0)