Subject: Re: [RFC] ident: support per-path configs by matching the path against a pattern

From: Jeff King <[email-masked]>
Date: Fri, 10 Jul 2015 11:43:08 -0400

On Fri, Jul 10, 2015 at 08:10:54AM -0700, Junio C Hamano wrote:

> I do agree it is a good feature to have to allow you to keep a
> centralized registry of possible configuration in a single place,
> e.g. $HOME/.gitconfig, and selectively apply pieces for multiple
> places.
> 
> Having said that, a few comments.
> 
>  - It feels very hacky to only do this for the ident.  You would
>    want to have, (conceptually, not necessarily at the syntax level)
>    something more along the lines of:
> 
>    	if path matches this pattern
>         	[user]
>                 	email = address
>                         name = name
> 	end
> 
>    to allow any configuration to be covered by this new "selectively
>    use from the centralized registry" feature.

Yeah, I agree it would be nice to cover all config keys. Since it's
syntactically difficult to add conditionals to the existing config
format, I tried to leave open a space for this in the "include" design.
That is, right now:

  [include]
  path = foo

will unconditionally include "foo". But something like:

  [include "gitdir:bar"]
  path = foo

could do so only when the "gitdir:bar" conditional is satisfied (where
that is just a syntax I made up to mean fnmatch("bar", $GIT_DIR)). So
like user.<pattern>.*, we still put our section-specific hack into one
special section, but that one place is capable of chaining to multiple
other config keys. :)

My only request is that any conditional we add have some prefix (like
"gitdir:") so that we have space to add more types later if we choose.

There's discussion on this topic somewhere on the list, but I didn't
bother to dig it up. I don't think it adds anything over what I
summarized above.

-Peff