test_expect_success 'check with trailing whitespace' '
echo "foo(); " > x &&
- ! git diff --check
+ test_must_fail git diff --check
'
# indent has space followed by hard tab
echo " foo();" > x &&
- ! git diff --check
+ test_must_fail git diff --check
'
echo "foo(); " > x &&
git add x &&
- ! git diff --cached --check
+ test_must_fail git diff --cached --check
'
# indent has space followed by hard tab
echo " foo();" > x &&
git add x &&
- ! git diff --cached --check
+ test_must_fail git diff --cached --check
'
echo "foo(); " > x &&
git add x &&
- ! git diff-index --check HEAD
+ test_must_fail git diff-index --check HEAD
'
# indent has space followed by hard tab
echo " foo();" > x &&
git add x &&
- ! git diff-index --check HEAD
+ test_must_fail git diff-index --check HEAD
'
echo "foo(); " > x &&
git add x &&
- ! git diff-index --cached --check HEAD
+ test_must_fail git diff-index --cached --check HEAD
'
# indent has space followed by hard tab
echo " foo();" > x &&
git add x &&
- ! git diff-index --cached --check HEAD
+ test_must_fail git diff-index --cached --check HEAD
'
echo "foo(); " > x &&
git commit -m "another commit" x &&
- ! git diff-tree --check HEAD^ HEAD
+ test_must_fail git diff-tree --check HEAD^ HEAD
'
# indent has space followed by hard tab
echo " foo();" > x &&
git commit -m "yet another" x &&
- ! git diff-tree --check HEAD^ HEAD
+ test_must_fail git diff-tree --check HEAD^ HEAD
'
git config core.whitespace "trailing-space" &&
echo "foo (); " > x &&
- ! git diff --check
+ test_must_fail git diff --check
'
# indent contains space followed by HT
git config core.whitespace "space-before-tab" &&
echo " foo (); " > x &&
- ! git diff --check
+ test_must_fail git diff --check
'
git config core.whitespace "indent-with-non-tab" &&
echo " foo ();" > x &&
- ! git diff --check
+ test_must_fail git diff --check
'
git config core.whitespace "indent-with-non-tab" &&
echo " foo ();" > x &&
- ! git diff --check
+ test_must_fail git diff --check
'
'
+test_expect_success 'checkdiff detects trailing blank lines' '
+ echo "foo();" >x &&
+ echo "" >>x &&
+ git diff --check | grep "ends with blank"
+'
+
test_done