@@ -19,9 +19,11 @@ cat >post.simple <<-\EOF
1919
2020 aeff = aeff * ( aaa )
2121EOF
22- cat > expect.letter-runs-are-words << -\EOF
22+ pre=$( git rev-parse --short $( git hash-object pre.simple) )
23+ post=$( git rev-parse --short $( git hash-object post.simple) )
24+ cat > expect.letter-runs-are-words << -EOF
2325 <BOLD>diff --git a/pre b/post<RESET>
24- <BOLD>index 330b04f..5ed8eff 100644<RESET>
26+ <BOLD>index $pre .. $post 100644<RESET>
2527 <BOLD>--- a/pre<RESET>
2628 <BOLD>+++ b/post<RESET>
2729 <CYAN>@@ -1,3 +1,7 @@<RESET>
@@ -33,9 +35,9 @@ cat >expect.letter-runs-are-words <<-\EOF
3335
3436 <GREEN>aeff = aeff * ( aaa<RESET> )
3537EOF
36- cat > expect.non-whitespace-is-word << -\ EOF
38+ cat > expect.non-whitespace-is-word << -EOF
3739 <BOLD>diff --git a/pre b/post<RESET>
38- <BOLD>index 330b04f..5ed8eff 100644<RESET>
40+ <BOLD>index $pre .. $post 100644<RESET>
3941 <BOLD>--- a/pre<RESET>
4042 <BOLD>+++ b/post<RESET>
4143 <CYAN>@@ -1,3 +1,7 @@<RESET>
@@ -49,9 +51,12 @@ cat >expect.non-whitespace-is-word <<-\EOF
4951EOF
5052
5153word_diff () {
54+ pre=$( git rev-parse --short $( git hash-object pre) ) &&
55+ post=$( git rev-parse --short $( git hash-object post) ) &&
5256 test_must_fail git diff --no-index " $@ " pre post > output &&
5357 test_decode_color < output > output.decrypted &&
54- test_cmp expect output.decrypted
58+ sed -e " 2s/index [^ ]*/index $pre ..$post /" expect > expected
59+ test_cmp expected output.decrypted
5560}
5661
5762test_language_driver () {
@@ -77,9 +82,9 @@ test_expect_success 'set up pre and post with runs of whitespace' '
7782'
7883
7984test_expect_success ' word diff with runs of whitespace' '
80- cat >expect <<-\ EOF &&
85+ cat >expect <<-EOF &&
8186 <BOLD>diff --git a/pre b/post<RESET>
82- <BOLD>index 330b04f..5ed8eff 100644<RESET>
87+ <BOLD>index $pre..$post 100644<RESET>
8388 <BOLD>--- a/pre<RESET>
8489 <BOLD>+++ b/post<RESET>
8590 <CYAN>@@ -1,3 +1,7 @@<RESET>
@@ -97,9 +102,9 @@ test_expect_success 'word diff with runs of whitespace' '
97102'
98103
99104test_expect_success ' --word-diff=porcelain' '
100- sed ' s/# .*$//' >expect <<-\ EOF &&
105+ sed ' s/# .*$//' >expect <<-EOF &&
101106 diff --git a/pre b/post
102- index 330b04f..5ed8eff 100644
107+ index $pre .. $post 100644
103108 --- a/pre
104109 +++ b/post
105110 @@ -1,3 +1,7 @@
@@ -121,9 +126,9 @@ test_expect_success '--word-diff=porcelain' '
121126'
122127
123128test_expect_success ' --word-diff=plain' '
124- cat > expect << -\ EOF &&
129+ cat > expect << -EOF &&
125130 diff --git a/pre b/post
126- index 330b04f..5ed8eff 100644
131+ index $pre .. $post 100644
127132 --- a/pre
128133 +++ b/post
129134 @@ -1,3 +1,7 @@
@@ -140,9 +145,9 @@ test_expect_success '--word-diff=plain' '
140145'
141146
142147test_expect_success ' --word-diff=plain --color' '
143- cat > expect << -\ EOF &&
148+ cat > expect << -EOF &&
144149 <BOLD>diff --git a/pre b/post<RESET>
145- <BOLD>index 330b04f..5ed8eff 100644<RESET>
150+ <BOLD>index $pre .. $post 100644<RESET>
146151 <BOLD>--- a/pre<RESET>
147152 <BOLD>+++ b/post<RESET>
148153 <CYAN>@@ -1,3 +1,7 @@<RESET>
@@ -158,9 +163,9 @@ test_expect_success '--word-diff=plain --color' '
158163'
159164
160165test_expect_success ' word diff without context' '
161- cat > expect << -\ EOF &&
166+ cat > expect << -EOF &&
162167 <BOLD>diff --git a/pre b/post<RESET>
163- <BOLD>index 330b04f..5ed8eff 100644<RESET>
168+ <BOLD>index $pre .. $post 100644<RESET>
164169 <BOLD>--- a/pre<RESET>
165170 <BOLD>+++ b/post<RESET>
166171 <CYAN>@@ -1 +1 @@<RESET>
@@ -207,9 +212,9 @@ test_expect_success 'command-line overrides config' '
207212'
208213
209214test_expect_success ' command-line overrides config: --word-diff-regex' '
210- cat > expect << -\ EOF &&
215+ cat > expect << -EOF &&
211216 <BOLD>diff --git a/pre b/post<RESET>
212- <BOLD>index 330b04f..5ed8eff 100644<RESET>
217+ <BOLD>index $pre .. $post 100644<RESET>
213218 <BOLD>--- a/pre<RESET>
214219 <BOLD>+++ b/post<RESET>
215220 <CYAN>@@ -1,3 +1,7 @@<RESET>
@@ -234,9 +239,9 @@ test_expect_success 'setup: remove diff driver regex' '
234239'
235240
236241test_expect_success ' use configured regex' '
237- cat > expect << -\ EOF &&
242+ cat > expect << -EOF &&
238243 <BOLD>diff --git a/pre b/post<RESET>
239- <BOLD>index 330b04f..5ed8eff 100644<RESET>
244+ <BOLD>index $pre .. $post 100644<RESET>
240245 <BOLD>--- a/pre<RESET>
241246 <BOLD>+++ b/post<RESET>
242247 <CYAN>@@ -1,3 +1,7 @@<RESET>
@@ -254,9 +259,11 @@ test_expect_success 'use configured regex' '
254259test_expect_success ' test parsing words for newline' '
255260 echo " aaa (aaa)" > pre &&
256261 echo " aaa (aaa) aaa" > post &&
257- cat > expect << -\EOF &&
262+ pre=$( git rev-parse --short $( git hash-object pre) ) &&
263+ post=$( git rev-parse --short $( git hash-object post) ) &&
264+ cat > expect << -EOF &&
258265 <BOLD>diff --git a/pre b/post<RESET>
259- <BOLD>index c29453b..be22f37 100644<RESET>
266+ <BOLD>index $pre .. $post 100644<RESET>
260267 <BOLD>--- a/pre<RESET>
261268 <BOLD>+++ b/post<RESET>
262269 <CYAN>@@ -1 +1 @@<RESET>
@@ -268,9 +275,11 @@ test_expect_success 'test parsing words for newline' '
268275test_expect_success ' test when words are only removed at the end' '
269276 echo " (:" > pre &&
270277 echo " (" > post &&
271- cat > expect << -\EOF &&
278+ pre=$( git rev-parse --short $( git hash-object pre) ) &&
279+ post=$( git rev-parse --short $( git hash-object post) ) &&
280+ cat > expect << -EOF &&
272281 <BOLD>diff --git a/pre b/post<RESET>
273- <BOLD>index 289cb9d..2d06f37 100644<RESET>
282+ <BOLD>index $pre .. $post 100644<RESET>
274283 <BOLD>--- a/pre<RESET>
275284 <BOLD>+++ b/post<RESET>
276285 <CYAN>@@ -1 +1 @@<RESET>
@@ -282,9 +291,11 @@ test_expect_success 'test when words are only removed at the end' '
282291test_expect_success ' --word-diff=none' '
283292 echo " (:" > pre &&
284293 echo " (" > post &&
285- cat > expect << -\EOF &&
294+ pre=$( git rev-parse --short $( git hash-object pre) ) &&
295+ post=$( git rev-parse --short $( git hash-object post) ) &&
296+ cat > expect << -EOF &&
286297 diff --git a/pre b/post
287- index 289cb9d..2d06f37 100644
298+ index $pre .. $post 100644
288299 --- a/pre
289300 +++ b/post
290301 @@ -1 +1 @@
@@ -317,16 +328,6 @@ test_language_driver ruby
317328test_language_driver tex
318329
319330test_expect_success ' word-diff with diff.sbe' '
320- cat > expect << -\EOF &&
321- diff --git a/pre b/post
322- index a1a53b5..bc8fe6d 100644
323- --- a/pre
324- +++ b/post
325- @@ -1,3 +1,3 @@
326- a
327-
328- [-b-]{+c+}
329- EOF
330331 cat > pre << -\EOF &&
331332 a
332333
@@ -337,21 +338,35 @@ test_expect_success 'word-diff with diff.sbe' '
337338
338339 c
339340 EOF
341+ pre=$( git rev-parse --short $( git hash-object pre) ) &&
342+ post=$( git rev-parse --short $( git hash-object post) ) &&
343+ cat > expect << -EOF &&
344+ diff --git a/pre b/post
345+ index $pre ..$post 100644
346+ --- a/pre
347+ +++ b/post
348+ @@ -1,3 +1,3 @@
349+ a
350+
351+ [-b-]{+c+}
352+ EOF
340353 test_config diff.suppress-blank-empty true &&
341354 word_diff --word-diff=plain
342355'
343356
344357test_expect_success ' word-diff with no newline at EOF' '
345- cat > expect << -\EOF &&
358+ printf " %s" " a a a a a" > pre &&
359+ printf " %s" " a a ab a a" > post &&
360+ pre=$( git rev-parse --short $( git hash-object pre) ) &&
361+ post=$( git rev-parse --short $( git hash-object post) ) &&
362+ cat > expect << -EOF &&
346363 diff --git a/pre b/post
347- index 7bf316e..3dd0303 100644
364+ index $pre .. $post 100644
348365 --- a/pre
349366 +++ b/post
350367 @@ -1 +1 @@
351368 a a [-a-]{+ab+} a a
352369 EOF
353- printf " %s" " a a a a a" > pre &&
354- printf " %s" " a a ab a a" > post &&
355370 word_diff --word-diff=plain
356371'
357372
0 commit comments