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
15 test_must_fail git
diff --no-index "$@" pre post
> output
&&
16 test_decode_color
<output
>output.decrypted
&&
17 test_cmp expect output.decrypted
37 <WHITE
>diff --git a
/pre b
/post
<RESET
>
38 <WHITE
>index
330b04f.
.5ed8eff
100644<RESET
>
39 <WHITE
>--- a
/pre
<RESET
>
40 <WHITE
>+++ b
/post
<RESET
>
41 <CYAN
>@@
-1,3 +1,7 @@
<RESET
>
42 <RED
>h
(4)<RESET
><GREEN
>h
(4),hh
[44]<RESET
>
48 <GREEN
>aeff
= aeff
* ( aaa
)<RESET
>
51 test_expect_success
'word diff with runs of whitespace' '
53 word_diff --color-words
58 <WHITE
>diff --git a
/pre b
/post
<RESET
>
59 <WHITE
>index
330b04f.
.5ed8eff
100644<RESET
>
60 <WHITE
>--- a
/pre
<RESET
>
61 <WHITE
>+++ b
/post
<RESET
>
62 <CYAN
>@@
-1,3 +1,7 @@
<RESET
>
63 h
(4),<GREEN
>hh
<RESET
>[44]
69 <GREEN
>aeff
= aeff
* ( aaa
<RESET
> )
71 cp expect expect.letter-runs-are-words
73 test_expect_success
'word diff with a regular expression' '
75 word_diff --color-words="[a-z]+"
79 test_expect_success
'set a diff driver' '
80 git config diff.testdriver.wordRegex "[^[:space:]]" &&
81 cat <<EOF > .gitattributes
87 test_expect_success
'option overrides .gitattributes' '
89 word_diff --color-words="[a-z]+"
94 <WHITE
>diff --git a
/pre b
/post
<RESET
>
95 <WHITE
>index
330b04f.
.5ed8eff
100644<RESET
>
96 <WHITE
>--- a
/pre
<RESET
>
97 <WHITE
>+++ b
/post
<RESET
>
98 <CYAN
>@@
-1,3 +1,7 @@
<RESET
>
99 h
(4)<GREEN
>,hh
[44]<RESET
>
105 <GREEN
>aeff
= aeff
* ( aaa
)<RESET
>
107 cp expect expect.non-whitespace-is-word
109 test_expect_success
'use regex supplied by driver' '
111 word_diff --color-words
115 test_expect_success
'set diff.wordRegex option' '
116 git config diff.wordRegex "[[:alnum:]]+"
119 cp expect.letter-runs-are-words expect
121 test_expect_success
'command-line overrides config' '
122 word_diff --color-words="[a-z]+"
125 cp expect.non-whitespace-is-word expect
127 test_expect_success
'.gitattributes override config' '
128 word_diff --color-words
131 test_expect_success
'remove diff driver regex' '
132 git config --unset diff.testdriver.wordRegex
136 <WHITE
>diff --git a
/pre b
/post
<RESET
>
137 <WHITE
>index
330b04f.
.5ed8eff
100644<RESET
>
138 <WHITE
>--- a
/pre
<RESET
>
139 <WHITE
>+++ b
/post
<RESET
>
140 <CYAN
>@@
-1,3 +1,7 @@
<RESET
>
141 h
(4),<GREEN
>hh
[44<RESET
>]
147 <GREEN
>aeff
= aeff
* ( aaa
<RESET
> )
150 test_expect_success
'use configured regex' '
151 word_diff --color-words
154 echo 'aaa (aaa)' > pre
155 echo 'aaa (aaa) aaa' > post
158 <WHITE
>diff --git a
/pre b
/post
<RESET
>
159 <WHITE
>index c29453b..be22f37
100644<RESET
>
160 <WHITE
>--- a
/pre
<RESET
>
161 <WHITE
>+++ b
/post
<RESET
>
162 <CYAN
>@@
-1 +1 @@
<RESET
>
163 aaa
(aaa
) <GREEN
>aaa
<RESET
>
166 test_expect_success
'test parsing words for newline' '
168 word_diff --color-words="a+"
177 <WHITE
>diff --git a
/pre b
/post
<RESET
>
178 <WHITE
>index
289cb9d.
.2d06f37
100644<RESET
>
179 <WHITE
>--- a
/pre
<RESET
>
180 <WHITE
>+++ b
/post
<RESET
>
181 <CYAN
>@@
-1 +1 @@
<RESET
>
185 test_expect_success
'test when words are only removed at the end' '
187 word_diff --color-words=.