archive: move parameter parsing code to archive.c
[git/jnareb-git/bp-gitweb.git] / t / t4019-diff-wserror.sh
blob0d9cbb62615c0d94da784f63907989988b0e8151
1 #!/bin/sh
3 test_description='diff whitespace error detection'
5 . ./test-lib.sh
7 test_expect_success setup '
9 git config diff.color.whitespace "blue reverse" &&
10 >F &&
11 git add F &&
12 echo " Eight SP indent" >>F &&
13 echo " HT and SP indent" >>F &&
14 echo "With trailing SP " >>F &&
15 echo "Carriage ReturnQ" | tr Q "\015" >>F &&
16 echo "No problem" >>F
20 blue_grep='7;34m' ;# ESC [ 7 ; 3 4 m
22 test_expect_success default '
24 git diff --color >output
25 grep "$blue_grep" output >error
26 grep -v "$blue_grep" output >normal
28 grep Eight normal >/dev/null &&
29 grep HT error >/dev/null &&
30 grep With error >/dev/null &&
31 grep Return error >/dev/null &&
32 grep No normal >/dev/null
36 test_expect_success 'without -trail' '
38 git config core.whitespace -trail
39 git diff --color >output
40 grep "$blue_grep" output >error
41 grep -v "$blue_grep" output >normal
43 grep Eight normal >/dev/null &&
44 grep HT error >/dev/null &&
45 grep With normal >/dev/null &&
46 grep Return normal >/dev/null &&
47 grep No normal >/dev/null
51 test_expect_success 'without -trail (attribute)' '
53 git config --unset core.whitespace
54 echo "F whitespace=-trail" >.gitattributes
55 git diff --color >output
56 grep "$blue_grep" output >error
57 grep -v "$blue_grep" output >normal
59 grep Eight normal >/dev/null &&
60 grep HT error >/dev/null &&
61 grep With normal >/dev/null &&
62 grep Return normal >/dev/null &&
63 grep No normal >/dev/null
67 test_expect_success 'without -space' '
69 rm -f .gitattributes
70 git config core.whitespace -space
71 git diff --color >output
72 grep "$blue_grep" output >error
73 grep -v "$blue_grep" output >normal
75 grep Eight normal >/dev/null &&
76 grep HT normal >/dev/null &&
77 grep With error >/dev/null &&
78 grep Return error >/dev/null &&
79 grep No normal >/dev/null
83 test_expect_success 'without -space (attribute)' '
85 git config --unset core.whitespace
86 echo "F whitespace=-space" >.gitattributes
87 git diff --color >output
88 grep "$blue_grep" output >error
89 grep -v "$blue_grep" output >normal
91 grep Eight normal >/dev/null &&
92 grep HT normal >/dev/null &&
93 grep With error >/dev/null &&
94 grep Return error >/dev/null &&
95 grep No normal >/dev/null
99 test_expect_success 'with indent-non-tab only' '
101 rm -f .gitattributes
102 git config core.whitespace indent,-trailing,-space
103 git diff --color >output
104 grep "$blue_grep" output >error
105 grep -v "$blue_grep" output >normal
107 grep Eight error >/dev/null &&
108 grep HT normal >/dev/null &&
109 grep With normal >/dev/null &&
110 grep Return normal >/dev/null &&
111 grep No normal >/dev/null
115 test_expect_success 'with indent-non-tab only (attribute)' '
117 git config --unset core.whitespace
118 echo "F whitespace=indent,-trailing,-space" >.gitattributes
119 git diff --color >output
120 grep "$blue_grep" output >error
121 grep -v "$blue_grep" output >normal
123 grep Eight error >/dev/null &&
124 grep HT normal >/dev/null &&
125 grep With normal >/dev/null &&
126 grep Return normal >/dev/null &&
127 grep No normal >/dev/null
131 test_expect_success 'with cr-at-eol' '
133 rm -f .gitattributes
134 git config core.whitespace cr-at-eol
135 git diff --color >output
136 grep "$blue_grep" output >error
137 grep -v "$blue_grep" output >normal
139 grep Eight normal >/dev/null &&
140 grep HT error >/dev/null &&
141 grep With error >/dev/null &&
142 grep Return normal >/dev/null &&
143 grep No normal >/dev/null
147 test_expect_success 'with cr-at-eol (attribute)' '
149 git config --unset core.whitespace
150 echo "F whitespace=trailing,cr-at-eol" >.gitattributes
151 git diff --color >output
152 grep "$blue_grep" output >error
153 grep -v "$blue_grep" output >normal
155 grep Eight normal >/dev/null &&
156 grep HT error >/dev/null &&
157 grep With error >/dev/null &&
158 grep Return normal >/dev/null &&
159 grep No normal >/dev/null
163 test_done