@@ -19,9 +19,11 @@ cat >post.simple <<-\EOF
19
19
20
20
aeff = aeff * ( aaa )
21
21
EOF
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
23
25
<BOLD>diff --git a/pre b/post<RESET>
24
- <BOLD>index 330b04f..5ed8eff 100644<RESET>
26
+ <BOLD>index $pre .. $post 100644<RESET>
25
27
<BOLD>--- a/pre<RESET>
26
28
<BOLD>+++ b/post<RESET>
27
29
<CYAN>@@ -1,3 +1,7 @@<RESET>
@@ -33,9 +35,9 @@ cat >expect.letter-runs-are-words <<-\EOF
33
35
34
36
<GREEN>aeff = aeff * ( aaa<RESET> )
35
37
EOF
36
- cat > expect.non-whitespace-is-word << -\ EOF
38
+ cat > expect.non-whitespace-is-word << -EOF
37
39
<BOLD>diff --git a/pre b/post<RESET>
38
- <BOLD>index 330b04f..5ed8eff 100644<RESET>
40
+ <BOLD>index $pre .. $post 100644<RESET>
39
41
<BOLD>--- a/pre<RESET>
40
42
<BOLD>+++ b/post<RESET>
41
43
<CYAN>@@ -1,3 +1,7 @@<RESET>
@@ -49,9 +51,12 @@ cat >expect.non-whitespace-is-word <<-\EOF
49
51
EOF
50
52
51
53
word_diff () {
54
+ pre=$( git rev-parse --short $( git hash-object pre) ) &&
55
+ post=$( git rev-parse --short $( git hash-object post) ) &&
52
56
test_must_fail git diff --no-index " $@ " pre post > output &&
53
57
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
55
60
}
56
61
57
62
test_language_driver () {
@@ -77,9 +82,9 @@ test_expect_success 'set up pre and post with runs of whitespace' '
77
82
'
78
83
79
84
test_expect_success ' word diff with runs of whitespace' '
80
- cat >expect <<-\ EOF &&
85
+ cat >expect <<-EOF &&
81
86
<BOLD>diff --git a/pre b/post<RESET>
82
- <BOLD>index 330b04f..5ed8eff 100644<RESET>
87
+ <BOLD>index $pre..$post 100644<RESET>
83
88
<BOLD>--- a/pre<RESET>
84
89
<BOLD>+++ b/post<RESET>
85
90
<CYAN>@@ -1,3 +1,7 @@<RESET>
@@ -97,9 +102,9 @@ test_expect_success 'word diff with runs of whitespace' '
97
102
'
98
103
99
104
test_expect_success ' --word-diff=porcelain' '
100
- sed ' s/# .*$//' >expect <<-\ EOF &&
105
+ sed ' s/# .*$//' >expect <<-EOF &&
101
106
diff --git a/pre b/post
102
- index 330b04f..5ed8eff 100644
107
+ index $pre .. $post 100644
103
108
--- a/pre
104
109
+++ b/post
105
110
@@ -1,3 +1,7 @@
@@ -121,9 +126,9 @@ test_expect_success '--word-diff=porcelain' '
121
126
'
122
127
123
128
test_expect_success ' --word-diff=plain' '
124
- cat > expect << -\ EOF &&
129
+ cat > expect << -EOF &&
125
130
diff --git a/pre b/post
126
- index 330b04f..5ed8eff 100644
131
+ index $pre .. $post 100644
127
132
--- a/pre
128
133
+++ b/post
129
134
@@ -1,3 +1,7 @@
@@ -140,9 +145,9 @@ test_expect_success '--word-diff=plain' '
140
145
'
141
146
142
147
test_expect_success ' --word-diff=plain --color' '
143
- cat > expect << -\ EOF &&
148
+ cat > expect << -EOF &&
144
149
<BOLD>diff --git a/pre b/post<RESET>
145
- <BOLD>index 330b04f..5ed8eff 100644<RESET>
150
+ <BOLD>index $pre .. $post 100644<RESET>
146
151
<BOLD>--- a/pre<RESET>
147
152
<BOLD>+++ b/post<RESET>
148
153
<CYAN>@@ -1,3 +1,7 @@<RESET>
@@ -158,9 +163,9 @@ test_expect_success '--word-diff=plain --color' '
158
163
'
159
164
160
165
test_expect_success ' word diff without context' '
161
- cat > expect << -\ EOF &&
166
+ cat > expect << -EOF &&
162
167
<BOLD>diff --git a/pre b/post<RESET>
163
- <BOLD>index 330b04f..5ed8eff 100644<RESET>
168
+ <BOLD>index $pre .. $post 100644<RESET>
164
169
<BOLD>--- a/pre<RESET>
165
170
<BOLD>+++ b/post<RESET>
166
171
<CYAN>@@ -1 +1 @@<RESET>
@@ -207,9 +212,9 @@ test_expect_success 'command-line overrides config' '
207
212
'
208
213
209
214
test_expect_success ' command-line overrides config: --word-diff-regex' '
210
- cat > expect << -\ EOF &&
215
+ cat > expect << -EOF &&
211
216
<BOLD>diff --git a/pre b/post<RESET>
212
- <BOLD>index 330b04f..5ed8eff 100644<RESET>
217
+ <BOLD>index $pre .. $post 100644<RESET>
213
218
<BOLD>--- a/pre<RESET>
214
219
<BOLD>+++ b/post<RESET>
215
220
<CYAN>@@ -1,3 +1,7 @@<RESET>
@@ -234,9 +239,9 @@ test_expect_success 'setup: remove diff driver regex' '
234
239
'
235
240
236
241
test_expect_success ' use configured regex' '
237
- cat > expect << -\ EOF &&
242
+ cat > expect << -EOF &&
238
243
<BOLD>diff --git a/pre b/post<RESET>
239
- <BOLD>index 330b04f..5ed8eff 100644<RESET>
244
+ <BOLD>index $pre .. $post 100644<RESET>
240
245
<BOLD>--- a/pre<RESET>
241
246
<BOLD>+++ b/post<RESET>
242
247
<CYAN>@@ -1,3 +1,7 @@<RESET>
@@ -254,9 +259,11 @@ test_expect_success 'use configured regex' '
254
259
test_expect_success ' test parsing words for newline' '
255
260
echo " aaa (aaa)" > pre &&
256
261
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 &&
258
265
<BOLD>diff --git a/pre b/post<RESET>
259
- <BOLD>index c29453b..be22f37 100644<RESET>
266
+ <BOLD>index $pre .. $post 100644<RESET>
260
267
<BOLD>--- a/pre<RESET>
261
268
<BOLD>+++ b/post<RESET>
262
269
<CYAN>@@ -1 +1 @@<RESET>
@@ -268,9 +275,11 @@ test_expect_success 'test parsing words for newline' '
268
275
test_expect_success ' test when words are only removed at the end' '
269
276
echo " (:" > pre &&
270
277
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 &&
272
281
<BOLD>diff --git a/pre b/post<RESET>
273
- <BOLD>index 289cb9d..2d06f37 100644<RESET>
282
+ <BOLD>index $pre .. $post 100644<RESET>
274
283
<BOLD>--- a/pre<RESET>
275
284
<BOLD>+++ b/post<RESET>
276
285
<CYAN>@@ -1 +1 @@<RESET>
@@ -282,9 +291,11 @@ test_expect_success 'test when words are only removed at the end' '
282
291
test_expect_success ' --word-diff=none' '
283
292
echo " (:" > pre &&
284
293
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 &&
286
297
diff --git a/pre b/post
287
- index 289cb9d..2d06f37 100644
298
+ index $pre .. $post 100644
288
299
--- a/pre
289
300
+++ b/post
290
301
@@ -1 +1 @@
@@ -317,16 +328,6 @@ test_language_driver ruby
317
328
test_language_driver tex
318
329
319
330
test_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
330
331
cat > pre << -\EOF &&
331
332
a
332
333
@@ -337,21 +338,35 @@ test_expect_success 'word-diff with diff.sbe' '
337
338
338
339
c
339
340
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
340
353
test_config diff.suppress-blank-empty true &&
341
354
word_diff --word-diff=plain
342
355
'
343
356
344
357
test_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 &&
346
363
diff --git a/pre b/post
347
- index 7bf316e..3dd0303 100644
364
+ index $pre .. $post 100644
348
365
--- a/pre
349
366
+++ b/post
350
367
@@ -1 +1 @@
351
368
a a [-a-]{+ab+} a a
352
369
EOF
353
- printf " %s" " a a a a a" > pre &&
354
- printf " %s" " a a ab a a" > post &&
355
370
word_diff --word-diff=plain
356
371
'
357
372
0 commit comments