3 test_description
='word diff colors'
7 test_expect_success setup
'
9 git config diff.color.old red
10 git config diff.color.new green
16 -e 's/.\[1m/<WHITE>/g' \
17 -e 's/.\[31m/<RED>/g' \
18 -e 's/.\[32m/<GREEN>/g' \
19 -e 's/.\[36m/<BROWN>/g' \
24 test_must_fail git
diff --no-index "$@" pre post
> output
&&
25 decrypt_color
< output
> output.decrypted
&&
26 test_cmp expect output.decrypted
46 <WHITE
>diff --git a
/pre b
/post
<RESET
>
47 <WHITE
>index
330b04f.
.5ed8eff
100644<RESET
>
48 <WHITE
>--- a
/pre
<RESET
>
49 <WHITE
>+++ b
/post
<RESET
>
50 <BROWN
>@@
-1,3 +1,7 @@
<RESET
>
51 <RED
>h
(4)<RESET
><GREEN
>h
(4),hh
[44]<RESET
>
57 <GREEN
>aeff
= aeff
* ( aaa
)<RESET
>
60 test_expect_success
'word diff with runs of whitespace' '
62 word_diff --color-words
67 <WHITE
>diff --git a
/pre b
/post
<RESET
>
68 <WHITE
>index
330b04f.
.5ed8eff
100644<RESET
>
69 <WHITE
>--- a
/pre
<RESET
>
70 <WHITE
>+++ b
/post
<RESET
>
71 <BROWN
>@@
-1,3 +1,7 @@
<RESET
>
72 h
(4),<GREEN
>hh
<RESET
>[44]
78 <GREEN
>aeff
= aeff
* ( aaa
<RESET
> )
80 cp expect expect.letter-runs-are-words
82 test_expect_success
'word diff with a regular expression' '
84 word_diff --color-words="[a-z]+"
88 test_expect_success
'set a diff driver' '
89 git config diff.testdriver.wordRegex "[^[:space:]]" &&
90 cat <<EOF > .gitattributes
96 test_expect_success
'option overrides .gitattributes' '
98 word_diff --color-words="[a-z]+"
103 <WHITE
>diff --git a
/pre b
/post
<RESET
>
104 <WHITE
>index
330b04f.
.5ed8eff
100644<RESET
>
105 <WHITE
>--- a
/pre
<RESET
>
106 <WHITE
>+++ b
/post
<RESET
>
107 <BROWN
>@@
-1,3 +1,7 @@
<RESET
>
108 h
(4)<GREEN
>,hh
[44]<RESET
>
114 <GREEN
>aeff
= aeff
* ( aaa
)<RESET
>
116 cp expect expect.non-whitespace-is-word
118 test_expect_success
'use regex supplied by driver' '
120 word_diff --color-words
124 test_expect_success
'set diff.wordRegex option' '
125 git config diff.wordRegex "[[:alnum:]]+"
128 cp expect.letter-runs-are-words expect
130 test_expect_success
'command-line overrides config' '
131 word_diff --color-words="[a-z]+"
134 cp expect.non-whitespace-is-word expect
136 test_expect_success
'.gitattributes override config' '
137 word_diff --color-words
140 test_expect_success
'remove diff driver regex' '
141 git config --unset diff.testdriver.wordRegex
145 <WHITE
>diff --git a
/pre b
/post
<RESET
>
146 <WHITE
>index
330b04f.
.5ed8eff
100644<RESET
>
147 <WHITE
>--- a
/pre
<RESET
>
148 <WHITE
>+++ b
/post
<RESET
>
149 <BROWN
>@@
-1,3 +1,7 @@
<RESET
>
150 h
(4),<GREEN
>hh
[44<RESET
>]
156 <GREEN
>aeff
= aeff
* ( aaa
<RESET
> )
159 test_expect_success
'use configured regex' '
160 word_diff --color-words
163 echo 'aaa (aaa)' > pre
164 echo 'aaa (aaa) aaa' > post
167 <WHITE
>diff --git a
/pre b
/post
<RESET
>
168 <WHITE
>index c29453b..be22f37
100644<RESET
>
169 <WHITE
>--- a
/pre
<RESET
>
170 <WHITE
>+++ b
/post
<RESET
>
171 <BROWN
>@@
-1 +1 @@
<RESET
>
172 aaa
(aaa
) <GREEN
>aaa
<RESET
>
175 test_expect_success
'test parsing words for newline' '
177 word_diff --color-words="a+"
186 <WHITE
>diff --git a
/pre b
/post
<RESET
>
187 <WHITE
>index
289cb9d.
.2d06f37
100644<RESET
>
188 <WHITE
>--- a
/pre
<RESET
>
189 <WHITE
>+++ b
/post
<RESET
>
190 <BROWN
>@@
-1 +1 @@
<RESET
>
194 test_expect_success
'test when words are only removed at the end' '
196 word_diff --color-words=.