merge-recursive: do not look at the index during recursive merge
authorJunio C Hamano <gitster@pobox.com>
Tue, 9 Jan 2018 18:05:51 +0000 (10:05 -0800)
committerJunio C Hamano <gitster@pobox.com>
Tue, 9 Jan 2018 18:39:30 +0000 (10:39 -0800)
commitf309e8e768ec5de97e8ab3dcd223f32865176290
treeb8f800c71e1805cca2cc51d544af406ace803d12
parent65170c07d466b18364e0d2b6a360900c073b600f
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>
merge-recursive.c
t/t3030-merge-recursive.sh