threads / discuss / 37735

Custom hunk-header with ignore case setting

Subject: Custom hunk-header with ignore case setting

## tl;dr

2 messages between Oct 15, 2014 and Oct 15, 2014.

replies: 1people: 2as markdown or json

Thomas Braun· Oct 15, 2014, 12:52 UTC · lore
Hi,

I'm working with a proprietary programming language which ignores case. I now started to write a custom version of diff.*.xfuncname and it is kind of ugly to always spell out all cases like [Ff][Uu][Nn][cC][Tt][Ii][oO][Nn].

I've seen that the builtin diff patterns in userdiff.c can be specified ignoring case using the IPATTERN macro.

One of the possible solutions would be to patch userdiff.c (patch courtesy of Johannes Schindelin):

-- snip --
diff --git a/userdiff.c b/userdiff.c
index fad52d6..f089e50 100644
--- a/userdiff.c
+++ b/userdiff.c
@@ -228,6 +228,9 @@ int userdiff_config(const char *k, const char *v)
 		return parse_funcname(&drv->funcname, k, v, 0);
 	if (!strcmp(type, "xfuncname"))
 		return parse_funcname(&drv->funcname, k, v, REG_EXTENDED);
+	if (!strcmp(type, "ixfuncname"))
+		return parse_funcname(&drv->funcname, k, v,
+				REG_EXTENDED | REG_ICASE);
 	if (!strcmp(type, "binary"))
 		return parse_tristate(&drv->binary, k, v);
 	if (!strcmp(type, "command"))
-- snap -

With a patch like that I would, of course, supply documentation and tests.

Is that something worth a try from my side?

An alternative solution would be to add something like pxfuncname which
understands PCREs which we we already support in git grep.

And yet another alternative would be that I send a patch enhancing userdiff.c
with a reasonable pattern for the programming language. But its community,
and especially intersected with git users, is not that large.

Thanks,
Thomas
Junio C Hamano· Oct 15, 2014, 19:35 UTC · re: Thomas Braun · lore

Re: Custom hunk-header with ignore case setting

Thomas Braun <thomas.braun@virtuell-zuhause.de> writes:
Show 21 quoted lines
> I've seen that the builtin diff patterns in userdiff.c can be
> specified ignoring case using the IPATTERN macro.
>
> One of the possible solutions would be to patch userdiff.c
> (patch courtesy of Johannes Schindelin):
>
> -- snip --
> diff --git a/userdiff.c b/userdiff.c
> index fad52d6..f089e50 100644
> --- a/userdiff.c
> +++ b/userdiff.c
> @@ -228,6 +228,9 @@ int userdiff_config(const char *k, const char *v)
>  		return parse_funcname(&drv->funcname, k, v, 0);
>  	if (!strcmp(type, "xfuncname"))
>  		return parse_funcname(&drv->funcname, k, v, REG_EXTENDED);
> +	if (!strcmp(type, "ixfuncname"))
> +		return parse_funcname(&drv->funcname, k, v,
> +				REG_EXTENDED | REG_ICASE);
>  	if (!strcmp(type, "binary"))
>  		return parse_tristate(&drv->binary, k, v);
>  	if (!strcmp(type, "command"))

I am not sure if we care deeply about supporting case insensitive payload in the first place, but the above change, unlike other possibilities, adds only small burden to the end users' cognitive load, and it looks like a sensible way to go forward.

Thanks.

← back to recent threads