3 test_description
='diff whitespace error detection'
7 test_expect_success setup
'
9 git config diff.color.whitespace "blue reverse" &&
12 echo " Eight SP indent" >>F &&
13 echo " HT and SP indent" >>F &&
14 echo "With trailing SP " >>F &&
19 blue_grep
='7;34m' ;# ESC [ 7 ; 3 4 m
21 test_expect_success default
'
23 git diff --color >output
24 grep "$blue_grep" output >error
25 grep -v "$blue_grep" output >normal
27 grep Eight normal >/dev/null &&
28 grep HT error >/dev/null &&
29 grep With error >/dev/null &&
30 grep No normal >/dev/null
34 test_expect_success
'without -trail' '
36 git config core.whitespace -trail
37 git diff --color >output
38 grep "$blue_grep" output >error
39 grep -v "$blue_grep" output >normal
41 grep Eight normal >/dev/null &&
42 grep HT error >/dev/null &&
43 grep With normal >/dev/null &&
44 grep No normal >/dev/null
48 test_expect_success
'without -trail (attribute)' '
50 git config --unset core.whitespace
51 echo "F whitespace=-trail" >.gitattributes
52 git diff --color >output
53 grep "$blue_grep" output >error
54 grep -v "$blue_grep" output >normal
56 grep Eight normal >/dev/null &&
57 grep HT error >/dev/null &&
58 grep With normal >/dev/null &&
59 grep No normal >/dev/null
63 test_expect_success
'without -space' '
66 git config core.whitespace -space
67 git diff --color >output
68 grep "$blue_grep" output >error
69 grep -v "$blue_grep" output >normal
71 grep Eight normal >/dev/null &&
72 grep HT normal >/dev/null &&
73 grep With error >/dev/null &&
74 grep No normal >/dev/null
78 test_expect_success
'without -space (attribute)' '
80 git config --unset core.whitespace
81 echo "F whitespace=-space" >.gitattributes
82 git diff --color >output
83 grep "$blue_grep" output >error
84 grep -v "$blue_grep" output >normal
86 grep Eight normal >/dev/null &&
87 grep HT normal >/dev/null &&
88 grep With error >/dev/null &&
89 grep No normal >/dev/null
93 test_expect_success
'with indent-non-tab only' '
96 git config core.whitespace indent,-trailing,-space
97 git diff --color >output
98 grep "$blue_grep" output >error
99 grep -v "$blue_grep" output >normal
101 grep Eight error >/dev/null &&
102 grep HT normal >/dev/null &&
103 grep With normal >/dev/null &&
104 grep No normal >/dev/null
108 test_expect_success
'with indent-non-tab only (attribute)' '
110 git config --unset core.whitespace
111 echo "F whitespace=indent,-trailing,-space" >.gitattributes
112 git diff --color >output
113 grep "$blue_grep" output >error
114 grep -v "$blue_grep" output >normal
116 grep Eight error >/dev/null &&
117 grep HT normal >/dev/null &&
118 grep With normal >/dev/null &&
119 grep No normal >/dev/null