t4034: diff.*.wordregex should not be "sticky" in --word-diff
The test case applies a custom wordRegex to one file in a diff, and expects that the default word splitting applies to the second file in the diff. But the custom wordRegex is also incorrectly used for the second file. Helped-by: Thomas Rast <trast@student.ethz.ch> Signed-off-by: Johannes Sixt <j6t@kdbg.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Johannes Sixt committed
Mar 14, 2012 at 20:50 UTC
62d39359af1a46de68b600c0dc73a98b78aa5523
1 file changed
+36
t/t4034-diff-words.sh
+36
@@ -3,6 +3,7 @@
3
test_description='word diff colors'
4
5
. ./test-lib.sh
6
+. "$TEST_DIRECTORY"/diff-lib.sh
7
8
cat >pre.simple <<-\EOF
9
h(4)
@@ -293,6 +294,10 @@ test_expect_success '--word-diff=none' '
294
word_diff --word-diff=plain --word-diff=none
295
'
296
297
+test_expect_success 'unset default driver' '
298
+ test_unconfig diff.wordregex
299
+'
300
+
301
test_language_driver bibtex
302
test_language_driver cpp
303
test_language_driver csharp
@@ -348,4 +353,35 @@ test_expect_success 'word-diff with no newline at EOF' '
353
word_diff --word-diff=plain
354
'
355
356
+test_expect_success 'setup history with two files' '
357
+ echo "a b; c" >a.tex &&
358
+ echo "a b; c" >z.txt &&
359
+ git add a.tex z.txt &&
360
+ git commit -minitial &&
361
+
362
+ # modify both
363
+ echo "a bx; c" >a.tex &&
364
+ echo "a bx; c" >z.txt &&
365
+ git commit -mmodified -a
366
+'
367
+
368
+test_expect_failure 'wordRegex for the first file does not apply to the second' '
369
+ echo "*.tex diff=tex" >.gitattributes &&
370
+ git config diff.tex.wordRegex "[a-z]+|." &&
371
+ cat >expect <<-\EOF &&
372
+ diff --git a/a.tex b/a.tex
373
+ --- a/a.tex
374
+ +++ b/a.tex
375
+ @@ -1 +1 @@
376
+ a [-b-]{+bx+}; c
377
+ diff --git a/z.txt b/z.txt
378
+ --- a/z.txt
379
+ +++ b/z.txt
380
+ @@ -1 +1 @@
381
+ a [-b;-]{+bx;+} c
382
+ EOF
383
+ git diff --word-diff HEAD~ >actual &&
384
+ compare_diff_patch expect actual
385
+'
386
+
387
test_done