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 <phillip.wood@dunelm.org.uk> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Phillip Wood committed Aug 20, 2021 at 15:40 UTC f2563c9ef3c028b5d4165df02fdfc0fcd613102d
2 files changed +22 -1
sequencer.c
+4 -1
@@ -3934,7 +3934,10 @@ static int do_merge(struct repository *r,
3934 strvec_pushf(&cmd.args,
3935 "-X%s", opts->xopts[k]);
3936 }
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");
3941 strvec_push(&cmd.args, "--no-ff");
3942 strvec_push(&cmd.args, "--no-log");
3943 strvec_push(&cmd.args, "--no-stat");
t/t3430-rebase-merges.sh
+18
@@ -187,6 +187,24 @@ test_expect_success 'merge -c commits before rewording and reloads todo-list' '
187 check_reworded_commits E H
188 '
189
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 +'
208 test_expect_success 'with a branch tip that was cherry-picked already' '
209 git checkout -b already-upstream main &&
210 base="$(git rev-parse --verify HEAD)" &&