rebase -r: always reword merge -c

If a merge can be fast-forwarded then make sure that we still edit the commit message if the user specifies -c. The implementation follows the same pattern that is used for ordinary rewords that are fast-forwarded. Signed-off-by: Phillip Wood <phillip.wood@dunelm.org.uk> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Phillip Wood committed May 2, 2019 at 11:22 UTC 6df8df083109b1aa37824fc1ebe2347f887afe34
2 files changed +18
sequencer.c
+5
@@ -3401,6 +3401,10 @@ static int do_merge(struct repository *r,
3401 rollback_lock_file(&lock);
3402 ret = fast_forward_to(r, &commit->object.oid,
3403 &head_commit->object.oid, 0, opts);
3404 + if (flags & TODO_EDIT_MERGE_MSG) {
3405 + run_commit_flags |= AMEND_MSG;
3406 + goto fast_forward_edit;
3407 + }
3408 goto leave_merge;
3409 }
3410
@@ -3504,6 +3508,7 @@ static int do_merge(struct repository *r,
3508 * value (a negative one would indicate that the `merge`
3509 * command needs to be rescheduled).
3510 */
3511 + fast_forward_edit:
3512 ret = !!run_git_commit(r, git_path_merge_msg(r), opts,
3513 run_commit_flags);
3514
t/t3430-rebase-merges.sh
+13
@@ -164,6 +164,19 @@ test_expect_success 'failed `merge <branch>` does not crash' '
164 grep "^Merge branch ${SQ}G${SQ}$" .git/rebase-merge/message
165 '
166
167 +test_expect_success 'fast-forward merge -c still rewords' '
168 + git checkout -b fast-forward-merge-c H &&
169 + (
170 + set_fake_editor &&
171 + FAKE_COMMIT_MESSAGE=edited \
172 + GIT_SEQUENCE_EDITOR="echo merge -c H G >" \
173 + git rebase -ir @^
174 + ) &&
175 + echo edited >expected &&
176 + git log --pretty=format:%B -1 >actual &&
177 + test_cmp expected actual
178 +'
179 +
180 test_expect_success 'with a branch tip that was cherry-picked already' '
181 git checkout -b already-upstream master &&
182 base="$(git rev-parse --verify HEAD)" &&