diff options
Diffstat (limited to 't')
-rw-r--r-- | t/.gitignore | 1 | ||||
-rwxr-xr-x | t/t4015-diff-whitespace.sh | 6 | ||||
-rwxr-xr-x | t/t4017-diff-retval.sh | 14 | ||||
-rwxr-xr-x | t/t4127-apply-same-fn.sh | 85 | ||||
-rwxr-xr-x | t/t7102-reset.sh | 47 | ||||
-rwxr-xr-x | t/t9700-perl-git.sh | 5 |
6 files changed, 158 insertions, 0 deletions
diff --git a/t/.gitignore b/t/.gitignore index 11ffd910c..b27e28008 100644 --- a/t/.gitignore +++ b/t/.gitignore @@ -1 +1,2 @@ /trash directory +/test-results diff --git a/t/t4015-diff-whitespace.sh b/t/t4015-diff-whitespace.sh index b7cc6b28e..0922c708f 100755 --- a/t/t4015-diff-whitespace.sh +++ b/t/t4015-diff-whitespace.sh @@ -335,4 +335,10 @@ test_expect_success 'line numbers in --check output are correct' ' ' +test_expect_success 'checkdiff detects trailing blank lines' ' + echo "foo();" >x && + echo "" >>x && + git diff --check | grep "ends with blank" +' + test_done diff --git a/t/t4017-diff-retval.sh b/t/t4017-diff-retval.sh index 0d0fb87f5..60dd2014d 100755 --- a/t/t4017-diff-retval.sh +++ b/t/t4017-diff-retval.sh @@ -113,4 +113,18 @@ test_expect_success 'check should test not just the last line' ' ' +test_expect_success 'check detects leftover conflict markers' ' + git reset --hard && + git checkout HEAD^ && + echo binary >>b && + git commit -m "side" b && + test_must_fail git merge master && + git add b && ( + git --no-pager diff --cached --check >test.out + test $? = 2 + ) && + test 3 = $(grep "conflict marker" test.out | wc -l) && + git reset --hard +' + test_done diff --git a/t/t4127-apply-same-fn.sh b/t/t4127-apply-same-fn.sh new file mode 100755 index 000000000..2a6ed77c6 --- /dev/null +++ b/t/t4127-apply-same-fn.sh @@ -0,0 +1,85 @@ +#!/bin/sh + +test_description='apply same filename' + +. ./test-lib.sh + +test_expect_success setup ' + for i in a b c d e f g h i j k l m + do + echo $i + done >same_fn && + cp same_fn other_fn && + git add same_fn other_fn && + git commit -m initial +' +test_expect_success 'apply same filename with independent changes' ' + sed -i -e "s/^d/z/" same_fn && + git diff > patch0 && + git add same_fn && + sed -i -e "s/^i/y/" same_fn && + git diff >> patch0 && + cp same_fn same_fn2 && + git reset --hard && + git-apply patch0 && + diff same_fn same_fn2 +' + +test_expect_success 'apply same filename with overlapping changes' ' + git reset --hard + sed -i -e "s/^d/z/" same_fn && + git diff > patch0 && + git add same_fn && + sed -i -e "s/^e/y/" same_fn && + git diff >> patch0 && + cp same_fn same_fn2 && + git reset --hard && + git-apply patch0 && + diff same_fn same_fn2 +' + +test_expect_success 'apply same new filename after rename' ' + git reset --hard + git mv same_fn new_fn + sed -i -e "s/^d/z/" new_fn && + git add new_fn && + git diff -M --cached > patch1 && + sed -i -e "s/^e/y/" new_fn && + git diff >> patch1 && + cp new_fn new_fn2 && + git reset --hard && + git apply --index patch1 && + diff new_fn new_fn2 +' + +test_expect_success 'apply same old filename after rename -- should fail.' ' + git reset --hard + git mv same_fn new_fn + sed -i -e "s/^d/z/" new_fn && + git add new_fn && + git diff -M --cached > patch1 && + git mv new_fn same_fn + sed -i -e "s/^e/y/" same_fn && + git diff >> patch1 && + git reset --hard && + test_must_fail git apply patch1 +' + +test_expect_success 'apply A->B (rename), C->A (rename), A->A -- should pass.' ' + git reset --hard + git mv same_fn new_fn + sed -i -e "s/^d/z/" new_fn && + git add new_fn && + git diff -M --cached > patch1 && + git commit -m "a rename" && + git mv other_fn same_fn + sed -i -e "s/^e/y/" same_fn && + git add same_fn && + git diff -M --cached >> patch1 && + sed -i -e "s/^g/x/" same_fn && + git diff >> patch1 && + git reset --hard HEAD^ && + git apply patch1 +' + +test_done diff --git a/t/t7102-reset.sh b/t/t7102-reset.sh index 39ba14148..96d15083f 100755 --- a/t/t7102-reset.sh +++ b/t/t7102-reset.sh @@ -428,4 +428,51 @@ test_expect_success '--mixed refreshes the index' ' test_cmp expect output ' +test_expect_success 'disambiguation (1)' ' + + git reset --hard && + >secondfile && + git add secondfile && + test_must_fail git reset secondfile && + test -z "$(git diff --cached --name-only)" && + test -f secondfile && + test ! -s secondfile + +' + +test_expect_success 'disambiguation (2)' ' + + git reset --hard && + >secondfile && + git add secondfile && + rm -f secondfile && + test_must_fail git reset secondfile && + test -n "$(git diff --cached --name-only -- secondfile)" && + test ! -f secondfile + +' + +test_expect_success 'disambiguation (3)' ' + + git reset --hard && + >secondfile && + git add secondfile && + rm -f secondfile && + test_must_fail git reset HEAD secondfile && + test -z "$(git diff --cached --name-only)" && + test ! -f secondfile + +' + +test_expect_success 'disambiguation (4)' ' + + git reset --hard && + >secondfile && + git add secondfile && + rm -f secondfile && + test_must_fail git reset -- secondfile && + test -z "$(git diff --cached --name-only)" && + test ! -f secondfile +' + test_done diff --git a/t/t9700-perl-git.sh b/t/t9700-perl-git.sh index b2fb9ece9..9706ee577 100755 --- a/t/t9700-perl-git.sh +++ b/t/t9700-perl-git.sh @@ -6,6 +6,11 @@ test_description='perl interface (Git.pm)' . ./test-lib.sh +perl -MTest::More -e 0 2>/dev/null || { + say_color skip "Perl Test::More unavailable, skipping test" + test_done +} + # set up test repository test_expect_success \ |