Commit graph

55 commits

Author SHA1 Message Date
Elijah Newren 2a669c341a merge-recursive: Avoid doubly merging rename/add conflict contents
When a commit moves A to B while another commit created B (or moved C to
B), and these two different commits serve as different merge-bases for a
later merge, c94736a (merge-recursive: don't segfault while handling
rename clashes 2009-07-30) added some special code to avoid segfaults.
Since that commit, the two versions of B are merged in place (which could
be potentially conflicting) and the intermediate result is used as the
virtual ancestor.

However, right before this special merge, try_merge was turned on, meaning
that process_renames() would try an alternative merge that ignores the
'add' part of the conflict, and, if the merge is clean, store that as the
new virtual ancestor.  This could cause incorrect merging of criss-cross
merges; it would typically result in just recording a slightly confusing
merge base, but in some cases it could cause silent acceptance of one side
of a merge as the final resolution when a conflict should have been
flagged.

When we do a special merge for such a rename/add conflict between
merge-bases, turn try_merge off to avoid an inappropriate second merge.

Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-09-29 17:37:04 -07:00
Elijah Newren f63622c0a9 t6036: Add testcase for undetected conflict
If merging two lines of development involves a rename/add conflict, and two
different people make such a merge but resolve it differently, and then
someone tries to merge the resulting two merges, then they should clearly
get a conflict due to the different resolutions from the previous
developers.  However, in some such cases the conflict would not be detected
and git would silently accept one of the two versions being merged as the
final merge resolution.

Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-09-29 17:32:37 -07:00
Elijah Newren 583942df09 t6036: Add a second testcase similar to the first but with content changes
c94736a (merge-recursive: don't segfault while handling rename clashes
2009-07-30) added t6036 with a testcase that involved dual renames and a
criss-cross merge.  Add a test that is nearly identical, but which also
involves content modification -- a case git currently does not merge
correctly.

Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-09-29 17:32:37 -07:00
Elijah Newren c976260d0f t6036: Test index and worktree state, not just that merge fails
c94736a (merge-recursive: don't segfault while handling rename clashes
2009-07-30) added this testcase with an interesting corner case test,
which previously had cased git to segfault.  This test ensures that the
segfault does not return and that the merge correctly fails; just add
some checks that verify the state of the index and worktree after the merge
are correct.

Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-09-29 17:32:37 -07:00
Junio C Hamano c94736a27f merge-recursive: don't segfault while handling rename clashes
When a branch moves A to B while the other branch created B (or moved C to
B), the code tried to rename one of them to B~something to preserve both
versions, and failed to register temporary resolution for the original
path B at stage#0 during virtual ancestor computation.  This left the
index in unmerged state and caused a segfault.

A better solution is to merge these two versions of B's in place and use
the (potentially conflicting) result as the intermediate merge result in
the virtual ancestor.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-07-30 19:25:05 -07:00