Skip to content

Commit 62d3935

Browse files
j6tgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Johannes Sixt <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent a460348 commit 62d3935

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

t/t4034-diff-words.sh

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
test_description='word diff colors'
44

55
. ./test-lib.sh
6+
. "$TEST_DIRECTORY"/diff-lib.sh
67

78
cat >pre.simple <<-\EOF
89
h(4)
@@ -293,6 +294,10 @@ test_expect_success '--word-diff=none' '
293294
word_diff --word-diff=plain --word-diff=none
294295
'
295296
297+
test_expect_success 'unset default driver' '
298+
test_unconfig diff.wordregex
299+
'
300+
296301
test_language_driver bibtex
297302
test_language_driver cpp
298303
test_language_driver csharp
@@ -348,4 +353,35 @@ test_expect_success 'word-diff with no newline at EOF' '
348353
word_diff --word-diff=plain
349354
'
350355
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+
351387
test_done

0 commit comments

Comments
 (0)