All of lore.kernel.org
 help / color / mirror / Atom feed
* Custom hunk-header with ignore case setting
@ 2014-10-15 12:52 Thomas Braun
  2014-10-15 19:35 ` Junio C Hamano
  0 siblings, 1 reply; 2+ messages in thread
From: Thomas Braun @ 2014-10-15 12:52 UTC (permalink / raw)
  To: GIT Mailing-list

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

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

* Re: Custom hunk-header with ignore case setting
  2014-10-15 12:52 Custom hunk-header with ignore case setting Thomas Braun
@ 2014-10-15 19:35 ` Junio C Hamano
  0 siblings, 0 replies; 2+ messages in thread
From: Junio C Hamano @ 2014-10-15 19:35 UTC (permalink / raw)
  To: Thomas Braun; +Cc: GIT Mailing-list

Thomas Braun <thomas.braun@virtuell-zuhause.de> writes:

> 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.

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

end of thread, other threads:[~2014-10-15 19:36 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-10-15 12:52 Custom hunk-header with ignore case setting Thomas Braun
2014-10-15 19:35 ` Junio C Hamano

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.