t3030: fix accidental success in symlink rename

In this test, we have merge two branches. On one branch, we renamed "a" to "e". On the other, we renamed "a" to "e" and then added a symlink pointing at "a" pointing to "e". The results for the test indicate that the merge should succeed, but also that "a" should no longer exist. Since both sides renamed "a" to the same destination, we will end up comparing those destinations for content. But what about what's left? One side (the rename only), replaced "a" with nothing. The other side replaced it with a symlink. The common base must also be nothing, because any "a" before this was meaningless (it was totally unrelated content that ended up getting renamed). The only sensible resolution is to keep the symlink. The rename-only side didn't touch the content versus the common base, and the other side added content. The 3-way merge dictates that we take the side with a change. And this gives the overall merge an intuitive result. One side made one change (a rename), and the other side made two changes: an identical rename, and an addition (that just happened to be at the same spot). The end result should contain both changes. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com> Signed-off-by: Elijah Newren <newren@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Jeff King committed Aug 11, 2011 at 23:20 UTC 814f7d902b6bcbb67ff8efa5e75eceb7b5fcc0d8
1 file changed +5 -2
t/t3030-merge-recursive.sh
+5 -2
@@ -267,7 +267,8 @@ test_expect_success 'setup 8' '
267 ln -s e a &&
268 git add a e &&
269 test_tick &&
270 - git commit -m "rename a->e, symlink a->e"
270 + git commit -m "rename a->e, symlink a->e" &&
271 + oln=`printf e | git hash-object --stdin`
272 fi
273 '
274
@@ -630,16 +631,18 @@ test_expect_success 'merge-recursive copy vs. rename' '
631
632 if test_have_prereq SYMLINKS
633 then
633 - test_expect_success 'merge-recursive rename vs. rename/symlink' '
634 + test_expect_failure 'merge-recursive rename vs. rename/symlink' '
635
636 git checkout -f rename &&
637 git merge rename-ln &&
638 ( git ls-tree -r HEAD ; git ls-files -s ) >actual &&
639 (
640 + echo "120000 blob $oln a"
641 echo "100644 blob $o0 b"
642 echo "100644 blob $o0 c"
643 echo "100644 blob $o0 d/e"
644 echo "100644 blob $o0 e"
645 + echo "120000 $oln 0 a"
646 echo "100644 $o0 0 b"
647 echo "100644 $o0 0 c"
648 echo "100644 $o0 0 d/e"