summaryrefslogtreecommitdiff
path: root/sequencer.c
diff options
context:
space:
mode:
authorJohannes Schindelin <johannes.schindelin@gmx.de>2018-11-12 23:25:58 (GMT)
committerJunio C Hamano <gitster@pobox.com>2018-11-13 03:04:00 (GMT)
commit85f8d9da2182690461e05034a4a697f766bb8eb1 (patch)
tree22fa8db06b0a2edab4274d12c6ab73b4395018af /sequencer.c
parentf08110ddd84438f4a8d69c145fae7f65fc91940f (diff)
downloadgit-85f8d9da2182690461e05034a4a697f766bb8eb1.zip
git-85f8d9da2182690461e05034a4a697f766bb8eb1.tar.gz
git-85f8d9da2182690461e05034a4a697f766bb8eb1.tar.bz2
rebase -r: do not write MERGE_HEAD unless needed
When we detect that a `merge` can be skipped because the merged commit is already an ancestor of HEAD, we do not need to commit, therefore writing the MERGE_HEAD file is useless. It is actually worse than useless: a subsequent `git commit` will pick it up and think that we want to merge that commit, still. To avoid that, move the code that writes the MERGE_HEAD file to a location where we already know that the `merge` cannot be skipped. 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.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/sequencer.c b/sequencer.c
index 9e1ab3a..7a9cd81 100644
--- a/sequencer.c
+++ b/sequencer.c
@@ -3191,10 +3191,6 @@ static int do_merge(struct commit *commit, const char *arg, int arg_len,
}
merge_commit = to_merge->item;
- write_message(oid_to_hex(&merge_commit->object.oid), GIT_SHA1_HEXSZ,
- git_path_merge_head(the_repository), 0);
- write_message("no-ff", 5, git_path_merge_mode(the_repository), 0);
-
bases = get_merge_bases(head_commit, merge_commit);
if (bases && oideq(&merge_commit->object.oid,
&bases->item->object.oid)) {
@@ -3203,6 +3199,10 @@ static int do_merge(struct commit *commit, const char *arg, int arg_len,
goto leave_merge;
}
+ write_message(oid_to_hex(&merge_commit->object.oid), GIT_SHA1_HEXSZ,
+ git_path_merge_head(the_repository), 0);
+ write_message("no-ff", 5, git_path_merge_mode(the_repository), 0);
+
for (j = bases; j; j = j->next)
commit_list_insert(j->item, &reversed);
free_commit_list(bases);