Skip to content

Commit cf772c6

Browse files
phillipwooddscho
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 8b16818 commit cf772c6

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

sequencer.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3401,6 +3401,10 @@ static int do_merge(struct repository *r,
34013401
rollback_lock_file(&lock);
34023402
ret = fast_forward_to(r, &commit->object.oid,
34033403
&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+
}
34043408
goto leave_merge;
34053409
}
34063410

@@ -3504,6 +3508,7 @@ static int do_merge(struct repository *r,
35043508
* value (a negative one would indicate that the `merge`
35053509
* command needs to be rescheduled).
35063510
*/
3511+
fast_forward_edit:
35073512
ret = !!run_git_commit(r, git_path_merge_msg(r), opts,
35083513
run_commit_flags);
35093514

t/t3430-rebase-merges.sh

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,19 @@ test_expect_success 'failed `merge <branch>` does not crash' '
164164
grep "^Merge branch ${SQ}G${SQ}$" .git/rebase-merge/message
165165
'
166166

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+
167180
test_expect_success 'with a branch tip that was cherry-picked already' '
168181
git checkout -b already-upstream master &&
169182
base="$(git rev-parse --verify HEAD)" &&

0 commit comments

Comments
 (0)