git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH v2 1/3] Demonstrate a bug in --word-diff where diff.*.wordregex is "sticky"

From
Junio C Hamano <gitster@pobox.com>
Date
Mar 14, 2012, 19:24 UTC
Message-ID
<7vsjhboujp.fsf@alter.siamese.dyndns.org>
In-Reply-To
<3bb99e938624ae674674b304c24c48b9dc05871b.1331749299.git.trast@student.ethz.ch>
Thomas Rast <trast@student.ethz.ch> writes:
Show 33 quoted lines
> 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
> +'
Isn't this unsafe if some of the tests before this one failed?
	test_unconfig diff.wordregex

By the way, I really loathe the change that gutted major parts out of t/test-lib.sh and moved them to another file; now I have to eyeball two files to write a response like this instead of one.

> +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]+|." &&

The use of files "a" and "z" as an example of pair of a tex and non tex input makes the test look overly artificial (why not a.tex vs z.txt or something?), but other than that, looks cleanly done.

Thanks.
Show 19 quoted lines
> +	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
Previous: Junio C HamanoNext: Johannes Sixt
Message 6 of 10 in “Demonstrate a bug in --word-diff where diff.*.wordregex is "sticky"”
  1. 1/3 Demonstrate a bug in --word-diff where diff.*.wordregex is "sticky"Thomas Rast, Mar 14, 2012
  2. 2/3 diff: refactor the word-diff setup from builtin_diff_cmdThomas Rast, Mar 14, 2012
  3. Junio C HamanoMar 14, 2012
  4. 3/3 diff: tweak a _copy_ of diff_options with word-diffThomas Rast, Mar 14, 2012
  5. Junio C HamanoMar 14, 2012
  6. Junio C HamanoMar 14, 2012
  7. 1/3 Demonstrate a bug in --word-diff where diff.*.wordregex is "sticky"Johannes Sixt, Mar 14, 2012
  8. Stefano LattariniMar 14, 2012
  9. Junio C HamanoMar 14, 2012
  10. Johannes SixtMar 14, 2012

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.