Skip to content

Commit b27eb49

Browse files
arachsysgitster
authored andcommitted
whitespace: tests for git-diff --check with tab-in-indent error class
[jc: with test fixes from J6t] Signed-off-by: Chris Webb <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 3e3ec2a commit b27eb49

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

t/t4015-diff-whitespace.sh

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -352,6 +352,48 @@ test_expect_success 'check tabs and spaces as indentation (indent-with-non-tab:
352352
353353
'
354354

355+
test_expect_success 'check tabs as indentation (tab-in-indent: off)' '
356+
357+
git config core.whitespace "-tab-in-indent" &&
358+
echo " foo ();" > x &&
359+
git diff --check
360+
361+
'
362+
363+
test_expect_success 'check tabs as indentation (tab-in-indent: on)' '
364+
365+
git config core.whitespace "tab-in-indent" &&
366+
echo " foo ();" > x &&
367+
test_must_fail git diff --check
368+
369+
'
370+
371+
test_expect_success 'check tabs and spaces as indentation (tab-in-indent: on)' '
372+
373+
git config core.whitespace "tab-in-indent" &&
374+
echo " foo ();" > x &&
375+
test_must_fail git diff --check
376+
377+
'
378+
379+
test_expect_success 'check tab-in-indent and indent-with-non-tab conflict' '
380+
381+
git config core.whitespace "tab-in-indent,indent-with-non-tab" &&
382+
echo "foo ();" > x &&
383+
test_must_fail git diff --check
384+
385+
'
386+
387+
test_expect_success 'check tab-in-indent excluded from wildcard whitespace attribute' '
388+
389+
git config --unset core.whitespace &&
390+
echo "x whitespace" > .gitattributes &&
391+
echo " foo ();" > x &&
392+
git diff --check &&
393+
rm -f .gitattributes
394+
395+
'
396+
355397
test_expect_success 'line numbers in --check output are correct' '
356398
357399
echo "" > x &&

0 commit comments

Comments
 (0)