summaryrefslogtreecommitdiff
path: root/sequencer.c
diff options
context:
space:
mode:
authorJohannes Schindelin <johannes.schindelin@gmx.de>2018-05-03 23:01:28 (GMT)
committerJunio C Hamano <gitster@pobox.com>2018-05-06 04:21:58 (GMT)
commit9c85a1c29c5ac26c94aa6eda8da9bbfbc6751785 (patch)
treeb3ae3b2c5961e13d4ec7c804f14ad29e1993aa0d /sequencer.c
parentebddf393964120628f60f6f5e435cde87cc209c6 (diff)
downloadgit-9c85a1c29c5ac26c94aa6eda8da9bbfbc6751785.zip
git-9c85a1c29c5ac26c94aa6eda8da9bbfbc6751785.tar.gz
git-9c85a1c29c5ac26c94aa6eda8da9bbfbc6751785.tar.bz2
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>
Diffstat (limited to 'sequencer.c')
-rw-r--r--sequencer.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/sequencer.c b/sequencer.c
index a783239..65a8c49 100644
--- a/sequencer.c
+++ b/sequencer.c
@@ -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;