git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 1/3] Demonstrate a bug in --word-diff where diff.*.wordregex is "sticky"
@ 2012-03-14 18:24 Thomas Rast
  2012-03-14 18:24 ` [PATCH 2/3] diff: refactor the word-diff setup from builtin_diff_cmd Thomas Rast
                   ` (2 more replies)
  0 siblings, 3 replies; 10+ messages in thread
From: Thomas Rast @ 2012-03-14 18:24 UTC (permalink / raw)
  To: Johannes Sixt; +Cc: Junio C Hamano, git

From: Johannes Sixt <j6t@kdbg.org>

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.

[tr: unset the diff.wordRegex variable to make the test meaningful]

Signed-off-by: Johannes Sixt <j6t@kdbg.org>
Signed-off-by: Thomas Rast <trast@student.ethz.ch>
---

Compared to your version, I added the first hunk.  Otherwise the
diff.wordRegex=[[:alnum:]]+ setting carries over and makes the test
fail even with the bug fixed.

I deliberately put it as early as possible, rather than into the setup
for your test, to avoid confusion next time someone patches that file.

 t/t4034-diff-words.sh |   37 +++++++++++++++++++++++++++++++++++++
 1 file changed, 37 insertions(+)

diff --git a/t/t4034-diff-words.sh b/t/t4034-diff-words.sh
index 5c20121..69e81f3 100755
--- a/t/t4034-diff-words.sh
+++ b/t/t4034-diff-words.sh
@@ -293,6 +293,10 @@ test_expect_success '--word-diff=none' '
 	word_diff --word-diff=plain --word-diff=none
 '
 
+test_expect_success 'unset default driver' '
+	git config --unset diff.wordregex
+'
+
 test_language_driver bibtex
 test_language_driver cpp
 test_language_driver csharp
@@ -348,4 +352,37 @@ test_expect_success 'word-diff with no newline at EOF' '
 	word_diff --word-diff=plain
 '
 
+test_expect_success 'setup history with two files' '
+	echo "a b; c" >a &&
+	echo "a b; c" >z &&
+	git add a z &&
+	git commit -minitial &&
+
+	# modify both
+	echo "a bx; c" >a &&
+	echo "a bx; c" >z &&
+	git commit -mmodified -a
+'
+
+test_expect_failure 'wordRegex for the first file does not apply to the second' '
+	echo "a diff=tex" >.gitattributes &&
+	git config diff.tex.wordRegex "[a-z]+|." &&
+	cat >expect <<-\EOF &&
+		diff --git a/a b/a
+		index 9823d38..b09f967 100644
+		--- a/a
+		+++ b/a
+		@@ -1 +1 @@
+		a [-b-]{+bx+}; c
+		diff --git a/z b/z
+		index 9823d38..b09f967 100644
+		--- a/z
+		+++ b/z
+		@@ -1 +1 @@
+		a [-b;-]{+bx;+} c
+	EOF
+	git diff --word-diff HEAD~ >actual
+	test_cmp expect actual
+'
+
 test_done
-- 
1.7.10.rc0.286.gd2cb29

^ permalink raw reply related	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2012-03-14 21:53 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-03-14 18:24 [PATCH v2 1/3] Demonstrate a bug in --word-diff where diff.*.wordregex is "sticky" Thomas Rast
2012-03-14 18:24 ` [PATCH 2/3] diff: refactor the word-diff setup from builtin_diff_cmd Thomas Rast
2012-03-14 19:26   ` Junio C Hamano
2012-03-14 18:24 ` [PATCH 3/3] diff: tweak a _copy_ of diff_options with word-diff Thomas Rast
2012-03-14 19:38   ` Junio C Hamano
2012-03-14 19:24 ` [PATCH v2 1/3] Demonstrate a bug in --word-diff where diff.*.wordregex is "sticky" Junio C Hamano
2012-03-14 19:50   ` [PATCH v3 " Johannes Sixt
2012-03-14 21:03     ` Stefano Lattarini
2012-03-14 21:38     ` Junio C Hamano
2012-03-14 21:53       ` Johannes Sixt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).