aboutsummaryrefslogtreecommitdiff
path: root/merge-recursive.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2018-01-09 10:05:51 -0800
committerJunio C Hamano <gitster@pobox.com>2018-01-09 10:39:30 -0800
commitf309e8e768ec5de97e8ab3dcd223f32865176290 (patch)
treeb8f800c71e1805cca2cc51d544af406ace803d12 /merge-recursive.c
parent65170c07d466b18364e0d2b6a360900c073b600f (diff)
downloadgit-f309e8e768ec5de97e8ab3dcd223f32865176290.tar.gz
git-f309e8e768ec5de97e8ab3dcd223f32865176290.tar.xz
merge-recursive: do not look at the index during recursive merge
When merging another branch into ours, if their tree is the same as the common ancestor's, we can declare that our tree represents the result of three-way merge. In such a case, the recursive merge backend incorrectly used to create a commit out of our index, even when the index has changes. A recent fix attempted to prevent this by adding a comparison between "our" tree and the index, but forgot that this check must be restricted only to the outermost merge. Inner merges performed by the recursive backend across merge bases are by definition made from scratch without having any local changes added to the index. The call to index_has_changes() during an inner merge is working on the index that has no relation to the merge being performed, preventing legitimate merges from getting carried out. Fix it by limiting the check to the outermost merge. Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'merge-recursive.c')
-rw-r--r--merge-recursive.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/merge-recursive.c b/merge-recursive.c
index be01f528c..c571778f9 100644
--- a/merge-recursive.c
+++ b/merge-recursive.c
@@ -1954,7 +1954,7 @@ int merge_trees(struct merge_options *o,
if (oid_eq(&common->object.oid, &merge->object.oid)) {
struct strbuf sb = STRBUF_INIT;
- if (index_has_changes(&sb)) {
+ if (!o->call_depth && index_has_changes(&sb)) {
err(o, _("Dirty index: cannot merge (dirty: %s)"),
sb.buf);
return 0;