rebase --rebase-merges: a "merge" into a new root is a fast-forward

When a user provides a todo list containing something like

	reset [new root]
	merge my-branch

let's do the same as if pulling into an orphan branch: simply
fast-forward.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Johannes Schindelin
2018-05-04 01:01:28 +02:00
committed by Junio C Hamano
parent ebddf39396
commit 9c85a1c29c
2 changed files with 25 additions and 0 deletions

View File

@ -2870,6 +2870,18 @@ static int do_merge(struct commit *commit, const char *arg, int arg_len,
goto leave_merge;
}
if (opts->have_squash_onto &&
!oidcmp(&head_commit->object.oid, &opts->squash_onto)) {
/*
* When the user tells us to "merge" something into a
* "[new root]", let's simply fast-forward to the merge head.
*/
rollback_lock_file(&lock);
ret = fast_forward_to(&merge_commit->object.oid,
&head_commit->object.oid, 0, opts);
goto leave_merge;
}
if (commit) {
const char *message = get_commit_buffer(commit, NULL);
const char *body;