Skip to content

Commit f2563c9

Browse files
phillipwoodgitster
authored andcommitted
rebase -r: fix merge -c with a merge strategy
If a rebase is started with a --strategy option other than "ort" or "recursive" then "merge -c" does not allow the user to reword the commit message. Signed-off-by: Phillip Wood <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent baf8ec8 commit f2563c9

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

sequencer.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3934,7 +3934,10 @@ static int do_merge(struct repository *r,
39343934
strvec_pushf(&cmd.args,
39353935
"-X%s", opts->xopts[k]);
39363936
}
3937-
strvec_push(&cmd.args, "--no-edit");
3937+
if (!(flags & TODO_EDIT_MERGE_MSG))
3938+
strvec_push(&cmd.args, "--no-edit");
3939+
else
3940+
strvec_push(&cmd.args, "--edit");
39383941
strvec_push(&cmd.args, "--no-ff");
39393942
strvec_push(&cmd.args, "--no-log");
39403943
strvec_push(&cmd.args, "--no-stat");

t/t3430-rebase-merges.sh

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,24 @@ test_expect_success 'merge -c commits before rewording and reloads todo-list' '
187187
check_reworded_commits E H
188188
'
189189

190+
test_expect_success 'merge -c rewords when a strategy is given' '
191+
git checkout -b merge-c-with-strategy H &&
192+
write_script git-merge-override <<-\EOF &&
193+
echo overridden$1 >G.t
194+
git add G.t
195+
EOF
196+
197+
PATH="$PWD:$PATH" \
198+
GIT_SEQUENCE_EDITOR="echo merge -c H G >" \
199+
GIT_EDITOR="echo edited >>" \
200+
git rebase --no-ff -ir -s override -Xxopt E &&
201+
test_write_lines overridden--xopt >expect &&
202+
test_cmp expect G.t &&
203+
test_write_lines H "" edited "" >expect &&
204+
git log --format=%B -1 >actual &&
205+
test_cmp expect actual
206+
207+
'
190208
test_expect_success 'with a branch tip that was cherry-picked already' '
191209
git checkout -b already-upstream main &&
192210
base="$(git rev-parse --verify HEAD)" &&

0 commit comments

Comments
 (0)