提交 18a1d895 编写于 作者: C Clemens Buchacher 提交者: Junio C Hamano

t7607: use test-lib functions and check MERGE_HEAD

Use the test_commit and test_path_is_missing
functions from the test library.

Also make sure that a merge which fails due to
pre-merge checks aborts properly and does not
leave MERGE_HEAD behind.

The "will not overwrite removed file" test is an
exception to this. It notices the untracked file
at a stage where the merge is already well under
way. Therefore we cannot abort the merge without
major restructuring. See the following thread for
more details.

http://mid.gmane.org/7vskopwxej.fsf@gitster.siamese.dyndns.orgSigned-off-by: NClemens Buchacher <drizzd@aon.at>
Signed-off-by: NJunio C Hamano <gitster@pobox.com>
上级 40d675f4
......@@ -7,48 +7,38 @@ Do not overwrite changes.'
. ./test-lib.sh
test_expect_success 'setup' '
echo c0 > c0.c &&
git add c0.c &&
git commit -m c0 &&
git tag c0 &&
echo c1 > c1.c &&
git add c1.c &&
git commit -m c1 &&
git tag c1 &&
test_commit c0 c0.c &&
test_commit c1 c1.c &&
test_commit c1a c1.c "c1 a" &&
git reset --hard c0 &&
echo c2 > c2.c &&
git add c2.c &&
git commit -m c2 &&
git tag c2 &&
git reset --hard c1 &&
echo "c1 a" > c1.c &&
git add c1.c &&
git commit -m "c1 a" &&
git tag c1a &&
test_commit c2 c2.c &&
echo "VERY IMPORTANT CHANGES" > important
'
test_expect_success 'will not overwrite untracked file' '
git reset --hard c1 &&
cat important > c2.c &&
cp important c2.c &&
test_must_fail git merge c2 &&
test_path_is_missing .git/MERGE_HEAD &&
test_cmp important c2.c
'
test_expect_success 'will not overwrite new file' '
git reset --hard c1 &&
cat important > c2.c &&
cp important c2.c &&
git add c2.c &&
test_must_fail git merge c2 &&
test_path_is_missing .git/MERGE_HEAD &&
test_cmp important c2.c
'
test_expect_success 'will not overwrite staged changes' '
git reset --hard c1 &&
cat important > c2.c &&
cp important c2.c &&
git add c2.c &&
rm c2.c &&
test_must_fail git merge c2 &&
test_path_is_missing .git/MERGE_HEAD &&
git checkout c2.c &&
test_cmp important c2.c
'
......@@ -57,7 +47,7 @@ test_expect_success 'will not overwrite removed file' '
git reset --hard c1 &&
git rm c1.c &&
git commit -m "rm c1.c" &&
cat important > c1.c &&
cp important c1.c &&
test_must_fail git merge c1a &&
test_cmp important c1.c
'
......@@ -66,9 +56,10 @@ test_expect_success 'will not overwrite re-added file' '
git reset --hard c1 &&
git rm c1.c &&
git commit -m "rm c1.c" &&
cat important > c1.c &&
cp important c1.c &&
git add c1.c &&
test_must_fail git merge c1a &&
test_path_is_missing .git/MERGE_HEAD &&
test_cmp important c1.c
'
......@@ -76,10 +67,11 @@ test_expect_success 'will not overwrite removed file with staged changes' '
git reset --hard c1 &&
git rm c1.c &&
git commit -m "rm c1.c" &&
cat important > c1.c &&
cp important c1.c &&
git add c1.c &&
rm c1.c &&
test_must_fail git merge c1a &&
test_path_is_missing .git/MERGE_HEAD &&
git checkout c1.c &&
test_cmp important c1.c
'
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册