2009-07-29 23:02:39 +02:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
test_description='merging when a directory was replaced with a symlink'
|
|
|
|
. ./test-lib.sh
|
|
|
|
|
2009-08-09 17:35:02 +02:00
|
|
|
if ! test_have_prereq SYMLINKS
|
|
|
|
then
|
|
|
|
say 'Symbolic links not supported, skipping tests.'
|
|
|
|
test_done
|
|
|
|
fi
|
|
|
|
|
2009-07-29 23:02:39 +02:00
|
|
|
test_expect_success 'create a commit where dir a/b changed to symlink' '
|
|
|
|
mkdir -p a/b/c a/b-2/c &&
|
|
|
|
> a/b/c/d &&
|
|
|
|
> a/b-2/c/d &&
|
|
|
|
> a/x &&
|
|
|
|
git add -A &&
|
|
|
|
git commit -m base &&
|
|
|
|
git tag start &&
|
|
|
|
rm -rf a/b &&
|
|
|
|
ln -s b-2 a/b &&
|
|
|
|
git add -A &&
|
|
|
|
git commit -m "dir to symlink"
|
|
|
|
'
|
|
|
|
|
2009-07-30 05:22:25 +02:00
|
|
|
test_expect_success 'keep a/b-2/c/d across checkout' '
|
2009-07-29 23:02:39 +02:00
|
|
|
git checkout HEAD^0 &&
|
|
|
|
git reset --hard master &&
|
|
|
|
git rm --cached a/b &&
|
|
|
|
git commit -m "untracked symlink remains" &&
|
|
|
|
git checkout start^0 &&
|
|
|
|
test -f a/b-2/c/d
|
|
|
|
'
|
|
|
|
|
2009-06-14 15:08:28 +02:00
|
|
|
test_expect_success 'checkout should not have deleted a/b-2/c/d' '
|
2009-07-29 23:02:39 +02:00
|
|
|
git checkout HEAD^0 &&
|
|
|
|
git reset --hard master &&
|
|
|
|
git checkout start^0 &&
|
|
|
|
test -f a/b-2/c/d
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'setup for merge test' '
|
|
|
|
git reset --hard &&
|
|
|
|
test -f a/b-2/c/d &&
|
|
|
|
echo x > a/x &&
|
|
|
|
git add a/x &&
|
|
|
|
git commit -m x &&
|
|
|
|
git tag baseline
|
|
|
|
'
|
|
|
|
|
traverse_trees(): handle D/F conflict case sanely
traverse_trees() is supposed to call its callback with all the matching
entries from the given trees. The current algorithm keeps a pointer to
each of the tree being traversed, and feeds the entry with the earliest
name to the callback.
This breaks down if the trees being traversed looks like this:
A B
t-1 t
t-2 u
t/a v
When we are currently looking at an entry "t-1" in tree A, and tree B has
returned "t", feeding "t" from the B and not feeding anything from A, only
because "t-1" sorts later than "t", will miss an entry for a subtree "t"
behind the current entry in tree A.
This introduces extended_entry_extract() helper function that gives what
name is expected from the tree, and implements a mechanism to look-ahead
in the tree object using it, to make sure such a case is handled sanely.
Traversal in tree A in the above example will first return "t" to match
that of B, and then the next request for an entry to A then returns "t-1".
This roughly corresponds to what Linus's "prepare for one-entry lookahead"
wanted to do, but because this does implement look ahead, t6035 and one more
test in t1012 reveal that the approach would not work without adjusting the
side that walks the index in unpack_trees() as well.
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2009-09-19 23:07:14 +02:00
|
|
|
test_expect_failure 'do not lose a/b-2/c/d in merge (resolve)' '
|
2009-07-29 23:02:39 +02:00
|
|
|
git reset --hard &&
|
|
|
|
git checkout baseline^0 &&
|
|
|
|
git merge -s resolve master &&
|
|
|
|
test -h a/b &&
|
|
|
|
test -f a/b-2/c/d
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_failure 'do not lose a/b-2/c/d in merge (recursive)' '
|
|
|
|
git reset --hard &&
|
|
|
|
git checkout baseline^0 &&
|
|
|
|
git merge -s recursive master &&
|
|
|
|
test -h a/b &&
|
|
|
|
test -f a/b-2/c/d
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_success 'setup a merge where dir a/b-2 changed to symlink' '
|
|
|
|
git reset --hard &&
|
|
|
|
git checkout start^0 &&
|
|
|
|
rm -rf a/b-2 &&
|
|
|
|
ln -s b a/b-2 &&
|
|
|
|
git add -A &&
|
|
|
|
git commit -m "dir a/b-2 to symlink" &&
|
|
|
|
git tag test2
|
|
|
|
'
|
|
|
|
|
2009-10-11 22:38:11 +02:00
|
|
|
test_expect_success 'merge should not have conflicts (resolve)' '
|
2009-07-29 23:02:39 +02:00
|
|
|
git reset --hard &&
|
|
|
|
git checkout baseline^0 &&
|
|
|
|
git merge -s resolve test2 &&
|
|
|
|
test -h a/b-2 &&
|
|
|
|
test -f a/b/c/d
|
|
|
|
'
|
|
|
|
|
|
|
|
test_expect_failure 'merge should not have conflicts (recursive)' '
|
|
|
|
git reset --hard &&
|
|
|
|
git checkout baseline^0 &&
|
|
|
|
git merge -s recursive test2 &&
|
|
|
|
test -h a/b-2 &&
|
|
|
|
test -f a/b/c/d
|
|
|
|
'
|
|
|
|
|
|
|
|
test_done
|