summaryrefslogtreecommitdiff
path: root/sequencer.c
diff options
context:
space:
mode:
authorJohannes Schindelin <johannes.schindelin@gmx.de>2018-04-25 12:29:31 (GMT)
committerJunio C Hamano <gitster@pobox.com>2018-04-26 03:28:43 (GMT)
commit7ccdf65b63f2f4a5e751d70b9788af3c9e16b6ab (patch)
tree4b13b7802f35f2f7d83cebf95f4ed88635eba6d3 /sequencer.c
parent537e7d61359233e95d2ca6ef6b9059afca8daa81 (diff)
downloadgit-7ccdf65b63f2f4a5e751d70b9788af3c9e16b6ab.zip
git-7ccdf65b63f2f4a5e751d70b9788af3c9e16b6ab.tar.gz
git-7ccdf65b63f2f4a5e751d70b9788af3c9e16b6ab.tar.bz2
rebase --rebase-merges: avoid "empty merges"
The `git merge` command does not allow merging commits that are already reachable from HEAD: `git merge HEAD^`, for example, will report that we are already up to date and not change a thing. In an interactive rebase, such a merge could occur previously, e.g. when competing (or slightly modified) versions of a patch series were applied upstream, and the user had to `git rebase --skip` all of the local commits, and the topic branch becomes "empty" as a consequence. Let's teach the todo command `merge` to behave the same as `git merge`. Seeing as it requires some low-level trickery to create such merges with Git's commands in the first place, we do not even have to bother to introduce an option to force `merge` to create such merge commits. 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.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/sequencer.c b/sequencer.c
index 558efc1..afa155c 100644
--- a/sequencer.c
+++ b/sequencer.c
@@ -2810,6 +2810,13 @@ static int do_merge(struct commit *commit, const char *arg, int arg_len,
write_message("no-ff", 5, git_path_merge_mode(), 0);
bases = get_merge_bases(head_commit, merge_commit);
+ if (bases && !oidcmp(&merge_commit->object.oid,
+ &bases->item->object.oid)) {
+ ret = 0;
+ /* skip merging an ancestor of HEAD */
+ goto leave_merge;
+ }
+
for (j = bases; j; j = j->next)
commit_list_insert(j->item, &reversed);
free_commit_list(bases);