]> git.ipfire.org Git - thirdparty/git.git/commitdiff
rebase -r: fix merge -c with a merge strategy
authorPhillip Wood <phillip.wood@dunelm.org.uk>
Fri, 20 Aug 2021 15:40:38 +0000 (15:40 +0000)
committerJunio C Hamano <gitster@pobox.com>
Mon, 23 Aug 2021 16:36:30 +0000 (09:36 -0700)
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>
sequencer.c
t/t3430-rebase-merges.sh

index c2cba5ed4b1771cddb94b998094bef1eaca8c408..a19980f62d922a453f57de4c9f0c7c9137098133 100644 (file)
@@ -3934,7 +3934,10 @@ static int do_merge(struct repository *r,
                                strvec_pushf(&cmd.args,
                                             "-X%s", opts->xopts[k]);
                }
-               strvec_push(&cmd.args, "--no-edit");
+               if (!(flags & TODO_EDIT_MERGE_MSG))
+                       strvec_push(&cmd.args, "--no-edit");
+               else
+                       strvec_push(&cmd.args, "--edit");
                strvec_push(&cmd.args, "--no-ff");
                strvec_push(&cmd.args, "--no-log");
                strvec_push(&cmd.args, "--no-stat");
index 183c3a238380721c536d010c4c2ec675e297f250..43c82d9a33b003d194e1ec7284e312e4e84337d7 100755 (executable)
@@ -187,6 +187,24 @@ test_expect_success 'merge -c commits before rewording and reloads todo-list' '
        check_reworded_commits E H
 '
 
+test_expect_success 'merge -c rewords when a strategy is given' '
+       git checkout -b merge-c-with-strategy H &&
+       write_script git-merge-override <<-\EOF &&
+       echo overridden$1 >G.t
+       git add G.t
+       EOF
+
+       PATH="$PWD:$PATH" \
+       GIT_SEQUENCE_EDITOR="echo merge -c H G >" \
+       GIT_EDITOR="echo edited >>" \
+               git rebase --no-ff -ir -s override -Xxopt E &&
+       test_write_lines overridden--xopt >expect &&
+       test_cmp expect G.t &&
+       test_write_lines H "" edited "" >expect &&
+       git log --format=%B -1 >actual &&
+       test_cmp expect actual
+
+'
 test_expect_success 'with a branch tip that was cherry-picked already' '
        git checkout -b already-upstream main &&
        base="$(git rev-parse --verify HEAD)" &&