Re: [PATCH] color-words: make regex configurable via attributes

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

On Wed, 14 Jan 2009, Thomas Rast wrote:

> diff --git a/Documentation/diff-options.txt b/Documentation/diff-options.txt
> index 2c1fa4b..ef0e2f5 100644
> --- a/Documentation/diff-options.txt
> +++ b/Documentation/diff-options.txt
> @@ -97,6 +97,9 @@ endif::git-format-patch[]
>  Optionally, you can pass a regular expression that tells Git what the
>  words are that you are looking for; The default is to interpret any
>  stretch of non-whitespace as a word.
> +The regex can also be set via a diff driver, see
> +linkgit:gitattributes[1]; giving it explicitly overrides any diff
> +driver setting.

How about making this an extra paragraph?

> diff --git a/Documentation/gitattributes.txt b/Documentation/gitattributes.txt
> index 8af22ec..17707ba 100644
> --- a/Documentation/gitattributes.txt
> +++ b/Documentation/gitattributes.txt
> @@ -317,6 +317,8 @@ patterns are available:
>  
>  - `bibtex` suitable for files with BibTeX coded references.
>  
> +- `cpp` suitable for source code in the C and C++ languages.
> +

How about "written in C or C++"?

> +A built-in pattern is provided for all languages listed in the last
> +section.

Wow.  But how about "previous section"?

> diff --git a/t/t4034-diff-words.sh b/t/t4034-diff-words.sh
> index 0ed7e53..d6731d1 100755
> --- a/t/t4034-diff-words.sh
> +++ b/t/t4034-diff-words.sh

That was fast!

> +test_expect_success 'use default supplied by driver' '
> +
> +	test_must_fail git diff --no-index --color-words \
> +		pre post > output &&
> +	decrypt_color < output > output.decrypted &&
> +	test_cmp expect-by-chars output.decrypted
> +
> +'

I am actually just about to post new revisions of the last two patches 
where this would read

	test_expect_success 'use default supplied by driver' '

		word_diff --color-words

	'

instead...

I don't want to get bitten by stupid mistakes again, though, so I let it 
run with valgrind while glancing over the code.  Stay tuned.

> +#define PATTERNS(name, pattern, wordregex)			\
> +	{ name, NULL, -1, { pattern, REG_EXTENDED }, NULL, wordregex }

You could get rid of that NULL if...

> diff --git a/userdiff.h b/userdiff.h
> index ba29457..2aab13e 100644
> --- a/userdiff.h
> +++ b/userdiff.h
> @@ -12,6 +12,7 @@ struct userdiff_driver {
>  	int binary;
>  	struct userdiff_funcname funcname;
>  	const char *textconv;
> +	const char *word_regex;
>  };

... you inserted word_regex before textconv.  In a way, I find this more 
logical, since both funcname and word_regex have sensible defaults 
(provided by you), whereas textconv is strictly a user's option.

Ciao,
Dscho

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux