Code

t3030: fix accidental success in symlink rename
authorJeff King <peff@peff.net>
Fri, 12 Aug 2011 05:20:23 +0000 (23:20 -0600)
committerJunio C Hamano <gitster@pobox.com>
Sun, 14 Aug 2011 21:19:39 +0000 (14:19 -0700)
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>
t/t3030-merge-recursive.sh

index 0c02d569520ddc81b32db7d248197562d00bd7ea..55ef1895d7fd15348c47a5dc4a7f93541a1d38c1 100755 (executable)
@@ -267,7 +267,8 @@ test_expect_success 'setup 8' '
                ln -s e a &&
                git add a e &&
                test_tick &&
-               git commit -m "rename a->e, symlink a->e"
+               git commit -m "rename a->e, symlink a->e" &&
+               oln=`printf e | git hash-object --stdin`
        fi
 '
 
@@ -630,16 +631,18 @@ test_expect_success 'merge-recursive copy vs. rename' '
 
 if test_have_prereq SYMLINKS
 then
-       test_expect_success 'merge-recursive rename vs. rename/symlink' '
+       test_expect_failure 'merge-recursive rename vs. rename/symlink' '
 
                git checkout -f rename &&
                git merge rename-ln &&
                ( git ls-tree -r HEAD ; git ls-files -s ) >actual &&
                (
+                       echo "120000 blob $oln  a"
                        echo "100644 blob $o0   b"
                        echo "100644 blob $o0   c"
                        echo "100644 blob $o0   d/e"
                        echo "100644 blob $o0   e"
+                       echo "120000 $oln 0     a"
                        echo "100644 $o0 0      b"
                        echo "100644 $o0 0      c"
                        echo "100644 $o0 0      d/e"