t6036, t6042: use test_create_repo to keep tests independent
These tests used pretty strong measures to get a clean slate:
git rm -rf . &&
git clean -fdqx &&
rm -rf .git &&
git init &&
It's easier, safer (what if a previous test has a bug and accidentally
changes into a directory outside the test path?), and allows re-inspecting
test setup later if we instead just use test_create_repo to put different
tests into separate sub-repositories.
Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
maint
Elijah Newren7 years agocommitted byJunio C Hamano
test_expect_success 'setup differently handled merges of directory/file conflict' '
git rm -rf . &&
git clean -fdqx &&
rm -rf .git &&
git init &&
>ignore-me &&
git add ignore-me &&
test_tick &&
git commit -m A &&
git tag A &&
git branch B &&
git checkout -b C &&
mkdir a &&
echo 10 >a/file &&
git add a/file &&
test_tick &&
git commit -m C &&
git checkout B &&
echo 5 >a &&
git add a &&
test_tick &&
git commit -m B &&
git checkout B^0 &&
test_must_fail git merge C &&
git clean -f &&
rm -rf a/ &&
echo 5 >a &&
git add a &&
test_tick &&
git commit -m D &&
git tag D &&
git checkout C^0 &&
test_must_fail git merge B &&
git clean -f &&
git rm --cached a &&
echo 10 >a/file &&
git add a/file &&
test_tick &&
git commit -m E1 &&
git tag E1 &&
git checkout C^0 &&
test_must_fail git merge B &&
git clean -f &&
git rm --cached a &&
printf "10\n11\n" >a/file &&
git add a/file &&
test_tick &&
git commit -m E2 &&
git tag E2
test_create_repo directory-file &&
(
cd directory-file &&
>ignore-me &&
git add ignore-me &&
test_tick &&
git commit -m A &&
git tag A &&
git branch B &&
git checkout -b C &&
mkdir a &&
echo 10 >a/file &&
git add a/file &&
test_tick &&
git commit -m C &&
git checkout B &&
echo 5 >a &&
git add a &&
test_tick &&
git commit -m B &&
git checkout B^0 &&
test_must_fail git merge C &&
git clean -f &&
rm -rf a/ &&
echo 5 >a &&
git add a &&
test_tick &&
git commit -m D &&
git tag D &&
git checkout C^0 &&
test_must_fail git merge B &&
git clean -f &&
git rm --cached a &&
echo 10 >a/file &&
git add a/file &&
test_tick &&
git commit -m E1 &&
git tag E1 &&
git checkout C^0 &&
test_must_fail git merge B &&
git clean -f &&
git rm --cached a &&
printf "10\n11\n" >a/file &&
git add a/file &&
test_tick &&
git commit -m E2 &&
git tag E2
)
'
test_expect_success 'merge of D & E1 fails but has appropriate contents' '
get_clean_checkout D^0 &&
(
cd directory-file &&
test_must_fail git merge -s recursive E1^0 &&
get_clean_checkout D^0 &&
test 2 -eq $(git ls-files -s | wc -l) &&
test 1 -eq $(git ls-files -u | wc -l) &&
test 0 -eq $(git ls-files -o | wc -l) &&
test_must_fail git merge -s recursive E1^0 &&
test $(git rev-parse :0:ignore-me) = $(git rev-parse A:ignore-me) &&
test $(git rev-parse :2:a) = $(git rev-parse B:a)
test 2 -eq $(git ls-files -s | wc -l) &&
test 1 -eq $(git ls-files -u | wc -l) &&
test 0 -eq $(git ls-files -o | wc -l) &&
test $(git rev-parse :0:ignore-me) = $(git rev-parse A:ignore-me) &&
test $(git rev-parse :2:a) = $(git rev-parse B:a)
)
'
test_expect_success 'merge of E1 & D fails but has appropriate contents' '
get_clean_checkout E1^0 &&
(
cd directory-file &&
get_clean_checkout E1^0 &&
test_must_fail git merge -s recursive D^0 &&
test_must_fail git merge -s recursive D^0 &&
test 2 -eq $(git ls-files -s | wc -l) &&
test 1 -eq $(git ls-files -u | wc -l) &&
test 0 -eq $(git ls-files -o | wc -l) &&
test 2 -eq $(git ls-files -s | wc -l) &&
test 1 -eq $(git ls-files -u | wc -l) &&
test 0 -eq $(git ls-files -o | wc -l) &&
test $(git rev-parse :0:ignore-me) = $(git rev-parse A:ignore-me) &&
test $(git rev-parse :3:a) = $(git rev-parse B:a)
test $(git rev-parse :0:ignore-me) = $(git rev-parse A:ignore-me) &&
test $(git rev-parse :3:a) = $(git rev-parse B:a)
)
'
test_expect_success 'merge of D & E2 fails but has appropriate contents' '
get_clean_checkout D^0 &&
(
cd directory-file &&
get_clean_checkout D^0 &&
test_must_fail git merge -s recursive E2^0 &&
test_must_fail git merge -s recursive E2^0 &&
test 4 -eq $(git ls-files -s | wc -l) &&
test 3 -eq $(git ls-files -u | wc -l) &&
test 1 -eq $(git ls-files -o | wc -l) &&
test 4 -eq $(git ls-files -s | wc -l) &&
test 3 -eq $(git ls-files -u | wc -l) &&
test 1 -eq $(git ls-files -o | wc -l) &&
test $(git rev-parse :2:a) = $(git rev-parse B:a) &&
test $(git rev-parse :3:a/file) = $(git rev-parse E2:a/file) &&
test $(git rev-parse :1:a/file) = $(git rev-parse C:a/file) &&
test $(git rev-parse :0:ignore-me) = $(git rev-parse A:ignore-me) &&
test $(git rev-parse :2:a) = $(git rev-parse B:a) &&
test $(git rev-parse :3:a/file) = $(git rev-parse E2:a/file) &&
test $(git rev-parse :1:a/file) = $(git rev-parse C:a/file) &&
test $(git rev-parse :0:ignore-me) = $(git rev-parse A:ignore-me) &&
test -f a~HEAD
test -f a~HEAD
)
'
test_expect_success 'merge of E2 & D fails but has appropriate contents' '
get_clean_checkout E2^0 &&
(
cd directory-file &&
test_must_fail git merge -s recursive D^0 &&
get_clean_checkout E2^0 &&
test 4 -eq $(git ls-files -s | wc -l) &&
test 3 -eq $(git ls-files -u | wc -l) &&
test 1 -eq $(git ls-files -o | wc -l) &&
test_must_fail git merge -s recursive D^0 &&
test $(git rev-parse :3:a) = $(git rev-parse B:a) &&
test $(git rev-parse :2:a/file) = $(git rev-parse E2:a/file) &&
test $(git rev-parse :1:a/file) = $(git rev-parse C:a/file) &&
test $(git rev-parse :0:ignore-me) = $(git rev-parse A:ignore-me) &&
test 4 -eq $(git ls-files -s | wc -l) &&
test 3 -eq $(git ls-files -u | wc -l) &&
test 1 -eq $(git ls-files -o | wc -l) &&
test -f a~D^0
test $(git rev-parse :3:a) = $(git rev-parse B:a) &&
test $(git rev-parse :2:a/file) = $(git rev-parse E2:a/file) &&
test $(git rev-parse :1:a/file) = $(git rev-parse C:a/file) &&
test $(git rev-parse :0:ignore-me) = $(git rev-parse A:ignore-me) &&
test -f a~D^0
)
'
#
@ -492,52 +531,55 @@ test_expect_success 'merge of E2 & D fails but has appropriate contents' '
@@ -492,52 +531,55 @@ test_expect_success 'merge of E2 & D fails but has appropriate contents' '
# but that may cancel out at the final merge stage".
test_expect_success 'setup rename/rename(1to2)/modify followed by what looks like rename/rename(2to1)/modify' '
git reset --hard &&
git rm -rf . &&
git clean -fdqx &&
rm -rf .git &&
git init &&
printf "1\n2\n3\n4\n5\n6\n" >a &&
git add a &&
git commit -m A &&
git tag A &&
git checkout -b B A &&
git mv a b &&
echo 7 >>b &&
git add -u &&
git commit -m B &&
git checkout -b C A &&
git mv a c &&
git commit -m C &&
git checkout -q B^0 &&
git merge --no-commit -s ours C^0 &&
git mv b newname &&
git commit -m "Merge commit C^0 into HEAD" &&
git tag D &&
git checkout -q C^0 &&
git merge --no-commit -s ours B^0 &&
git mv c newname &&
printf "7\n8\n" >>newname &&
git add -u &&
git commit -m "Merge commit B^0 into HEAD" &&
git tag E
test_create_repo rename-squared-squared &&
(
cd rename-squared-squared &&
printf "1\n2\n3\n4\n5\n6\n" >a &&
git add a &&
git commit -m A &&
git tag A &&
git checkout -b B A &&
git mv a b &&
echo 7 >>b &&
git add -u &&
git commit -m B &&
git checkout -b C A &&
git mv a c &&
git commit -m C &&
git checkout -q B^0 &&
git merge --no-commit -s ours C^0 &&
git mv b newname &&
git commit -m "Merge commit C^0 into HEAD" &&
git tag D &&
git checkout -q C^0 &&
git merge --no-commit -s ours B^0 &&
git mv c newname &&
printf "7\n8\n" >>newname &&
git add -u &&
git commit -m "Merge commit B^0 into HEAD" &&
git tag E
)
'
test_expect_success 'handle rename/rename(1to2)/modify followed by what looks like rename/rename(2to1)/modify' '
git checkout D^0 &&
(
cd rename-squared-squared &&
git merge -s recursive E^0 &&
git checkout D^0 &&
test 1 -eq $(git ls-files -s | wc -l) &&
test 0 -eq $(git ls-files -u | wc -l) &&
test 0 -eq $(git ls-files -o | wc -l) &&
git merge -s recursive E^0 &&
test $(git rev-parse HEAD:newname) = $(git rev-parse E:newname)
test 1 -eq $(git ls-files -s | wc -l) &&
test 0 -eq $(git ls-files -u | wc -l) &&
test 0 -eq $(git ls-files -o | wc -l) &&
test $(git rev-parse HEAD:newname) = $(git rev-parse E:newname)
)
'
#
@ -562,59 +604,63 @@ test_expect_success 'handle rename/rename(1to2)/modify followed by what looks li
@@ -562,59 +604,63 @@ test_expect_success 'handle rename/rename(1to2)/modify followed by what looks li
# renaming carefully (both in the virtual merge base and later), and getting