Skip to content


rebase -r: always reword merge -c
Browse files Browse the repository at this point in the history
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 <>
Signed-off-by: Junio C Hamano <>
  • Loading branch information
phillipwood authored and dscho committed May 21, 2019
1 parent 998e2d8 commit 97d9140
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
5 changes: 5 additions & 0 deletions sequencer.c
Original file line number Diff line number Diff line change
Expand Up @@ -3249,6 +3249,10 @@ static int do_merge(struct repository *r,
ret = fast_forward_to(r, &commit->object.oid,
&head_commit->object.oid, 0, opts);
if (flags & TODO_EDIT_MERGE_MSG) {
run_commit_flags |= AMEND_MSG;
goto fast_forward_edit;
goto leave_merge;

Expand Down Expand Up @@ -3352,6 +3356,7 @@ static int do_merge(struct repository *r,
* value (a negative one would indicate that the `merge`
* command needs to be rescheduled).
ret = !!run_git_commit(r, git_path_merge_msg(r), opts,

Expand Down
13 changes: 13 additions & 0 deletions t/
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,19 @@ test_expect_success 'failed `merge <branch>` does not crash' '
grep "^Merge branch ${SQ}G${SQ}$" .git/rebase-merge/message

test_expect_success 'fast-forward merge -c still rewords' '
git checkout -b fast-forward-merge-c H &&
set_fake_editor &&
GIT_SEQUENCE_EDITOR="echo merge -c H G >" \
git rebase -ir @^
) &&
echo edited >expected &&
git log --pretty=format:%B -1 >actual &&
test_cmp expected actual

test_expect_success 'with a branch tip that was cherry-picked already' '
git checkout -b already-upstream master &&
base="$(git rev-parse --verify HEAD)" &&
Expand Down

0 comments on commit 97d9140

Please sign in to comment.