[PATCH 26/37] merge-recursive: Avoid doubly merging rename/add conflict contents

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxx>
---
 merge-recursive.c                 |    1 +
 t/t6036-recursive-corner-cases.sh |    4 ++--
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/merge-recursive.c b/merge-recursive.c
index 5f528c1..178bbd8 100644
--- a/merge-recursive.c
+++ b/merge-recursive.c
@@ -1061,6 +1061,7 @@ static int process_renames(struct merge_options *o,
 						    mfi.sha,
 						    mfi.mode,
 						    ren1_dst);
+					try_merge = 0;
 				} else {
 					new_path = unique_path(o, ren1_dst, branch2);
 					output(o, 1, "Adding as %s instead", new_path);
diff --git a/t/t6036-recursive-corner-cases.sh b/t/t6036-recursive-corner-cases.sh
index 6c2b2bf..a2e5c5c 100755
--- a/t/t6036-recursive-corner-cases.sh
+++ b/t/t6036-recursive-corner-cases.sh
@@ -120,7 +120,7 @@ test_expect_success 'setup criss-cross + rename merges with basic modification'
 	git tag R2
 '
 
-test_expect_failure 'merge criss-cross + rename merges with basic modification' '
+test_expect_success 'merge criss-cross + rename merges with basic modification' '
 	git reset --hard &&
 	git checkout L2^0 &&
 
@@ -202,7 +202,7 @@ test_expect_success 'setup differently handled merges of rename/add conflict' '
 	git tag E
 '
 
-test_expect_failure 'git detects differently handled merges conflict' '
+test_expect_success 'git detects differently handled merges conflict' '
 	git reset --hard &&
 	git checkout D^0 &&
 
-- 
1.7.3.271.g16009

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]