git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* appending a pattern to the default "diff.cpp.xfuncname"
@ 2016-08-03 10:16 Laszlo Ersek
  2016-08-03 18:02 ` Jeff King
  0 siblings, 1 reply; 5+ messages in thread
From: Laszlo Ersek @ 2016-08-03 10:16 UTC (permalink / raw)
  To: public git mailing list

Hi,

I've used diff.<TYPE>.xfuncname with great success for file <TYPE>s that
I defined myself. However, now I would like to append an extra pattern
to the TYPE=cpp case (for which git has builtin patterns). Is there an
easy way to do this?

I figured I could open-code the builtin patterns from "userdiff.c", and
then append my new pattern to those, but it looks kinda gross :)

Thanks!
Laszlo

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

* Re: appending a pattern to the default "diff.cpp.xfuncname"
  2016-08-03 10:16 appending a pattern to the default "diff.cpp.xfuncname" Laszlo Ersek
@ 2016-08-03 18:02 ` Jeff King
  2016-08-03 18:12   ` Laszlo Ersek
  2016-08-03 18:34   ` Jakub Narębski
  0 siblings, 2 replies; 5+ messages in thread
From: Jeff King @ 2016-08-03 18:02 UTC (permalink / raw)
  To: Laszlo Ersek; +Cc: public git mailing list

On Wed, Aug 03, 2016 at 12:16:14PM +0200, Laszlo Ersek wrote:

> I've used diff.<TYPE>.xfuncname with great success for file <TYPE>s that
> I defined myself. However, now I would like to append an extra pattern
> to the TYPE=cpp case (for which git has builtin patterns). Is there an
> easy way to do this?
> 
> I figured I could open-code the builtin patterns from "userdiff.c", and
> then append my new pattern to those, but it looks kinda gross :)

Unfortunately, no, the config system has no notion of "append to this
value". So you are stuck with extracting the builtin value (which
annoyingly, you cannot even get without looking at the source code!),
and repeating it in your config file.

-Peff

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

* Re: appending a pattern to the default "diff.cpp.xfuncname"
  2016-08-03 18:02 ` Jeff King
@ 2016-08-03 18:12   ` Laszlo Ersek
  2016-08-03 18:34   ` Jakub Narębski
  1 sibling, 0 replies; 5+ messages in thread
From: Laszlo Ersek @ 2016-08-03 18:12 UTC (permalink / raw)
  To: Jeff King; +Cc: public git mailing list

On 08/03/16 20:02, Jeff King wrote:
> On Wed, Aug 03, 2016 at 12:16:14PM +0200, Laszlo Ersek wrote:
> 
>> I've used diff.<TYPE>.xfuncname with great success for file <TYPE>s that
>> I defined myself. However, now I would like to append an extra pattern
>> to the TYPE=cpp case (for which git has builtin patterns). Is there an
>> easy way to do this?
>>
>> I figured I could open-code the builtin patterns from "userdiff.c", and
>> then append my new pattern to those, but it looks kinda gross :)
> 
> Unfortunately, no, the config system has no notion of "append to this
> value". So you are stuck with extracting the builtin value (which
> annoyingly, you cannot even get without looking at the source code!),
> and repeating it in your config file.

Thank you for confirming!
Laszlo


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

* Re: appending a pattern to the default "diff.cpp.xfuncname"
  2016-08-03 18:02 ` Jeff King
  2016-08-03 18:12   ` Laszlo Ersek
@ 2016-08-03 18:34   ` Jakub Narębski
  2016-08-03 18:40     ` Jeff King
  1 sibling, 1 reply; 5+ messages in thread
From: Jakub Narębski @ 2016-08-03 18:34 UTC (permalink / raw)
  To: Jeff King, Laszlo Ersek; +Cc: public git mailing list

W dniu 03.08.2016 o 20:02, Jeff King pisze:
> On Wed, Aug 03, 2016 at 12:16:14PM +0200, Laszlo Ersek wrote:
> 
>> I've used diff.<TYPE>.xfuncname with great success for file <TYPE>s that
>> I defined myself. However, now I would like to append an extra pattern
>> to the TYPE=cpp case (for which git has builtin patterns). Is there an
>> easy way to do this?
>>
>> I figured I could open-code the builtin patterns from "userdiff.c", and
>> then append my new pattern to those, but it looks kinda gross :)
> 
> Unfortunately, no, the config system has no notion of "append to this
> value". 

And I think adding such capability would not be easy.  Well, perhaps
we could support '+=' in addition to '='?

>         So you are stuck with extracting the builtin value (which
> annoyingly, you cannot even get without looking at the source code!),
> and repeating it in your config file.

I wonder if `git var -l` could provide all default values :-P

-- 
Jakub Narębski


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

* Re: appending a pattern to the default "diff.cpp.xfuncname"
  2016-08-03 18:34   ` Jakub Narębski
@ 2016-08-03 18:40     ` Jeff King
  0 siblings, 0 replies; 5+ messages in thread
From: Jeff King @ 2016-08-03 18:40 UTC (permalink / raw)
  To: Jakub Narębski; +Cc: Laszlo Ersek, public git mailing list

On Wed, Aug 03, 2016 at 08:34:28PM +0200, Jakub Narębski wrote:

> > Unfortunately, no, the config system has no notion of "append to this
> > value". 
> 
> And I think adding such capability would not be easy.  Well, perhaps
> we could support '+=' in addition to '='?

We could, but it would be an incompatible syntactic change, which we've
so far managed to avoid.

> >         So you are stuck with extracting the builtin value (which
> > annoyingly, you cannot even get without looking at the source code!),
> > and repeating it in your config file.
> 
> I wonder if `git var -l` could provide all default values :-P

I had a similar thought, but it's quite difficult because of the way
that default values are structured in git. Most code uses initialization
of C variables (including structs) to set up default values, and then
overrides them if it sees relevant config.

So there is no central code to ask "what is the value of X if I don't
provide any config"? It literally requires dumping a bunch of variables.

One thing we could do is move all of those defaults into an "internal"
config that is baked into the executable, and then parse that at the
lowest-priority level of config. And then "git config --list
--show-origin" could presumably just dump it.

But that would mean parsing it at run-time in every program (which is
probably not _that_ much overhead, but does feel wrong). I'd also
suspect there are a few cases whose defaults are expressed in code,
rather than as single variable assignments, and couldn't be represented
as config at all.

-Peff

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

end of thread, other threads:[~2016-08-03 19:00 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-08-03 10:16 appending a pattern to the default "diff.cpp.xfuncname" Laszlo Ersek
2016-08-03 18:02 ` Jeff King
2016-08-03 18:12   ` Laszlo Ersek
2016-08-03 18:34   ` Jakub Narębski
2016-08-03 18:40     ` Jeff King

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).