git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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

From
Junio C Hamano <gitster@pobox.com>
Date
Jul 10, 2015, 15:10 UTC
Message-ID
<xmqqr3ogkpz5.fsf@gitster.dls.corp.google.com>
In-Reply-To
<0000014e7752e758-a0bf7acb-2d0f-4492-8004-8eeeb9b2f042-000000@eu-west-1.amazonses.com>
Sebastian Schuberth <sschuberth@gmail.com> writes:
Show 10 quoted lines
> Support per-path identities by configuring Git like
>
>     $ git config user.<pattern>.email <email address>
>
> e.g.
>
>     $ git config user.github.email sschuberth+github@gmail.com
>
> In this example, the middle "github" pattern is searched for
> case-insensitively in the absolute path name to the current git work tree.

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.
 - It is iffy to match the pattern with "working tree".  There are
   pros and cons but a viable alternative would be to match with the
   location of the $GIT_DIR.  Given that we now are slowly moving to
   a world where a single $GIT_DIR can have multiple working trees,
   and that user.name ultimately matters per-project you are
   contributing to, it is more likely that you would want to tie it
   to a local repository, i.e. $GIT_DIR, no matter where working
   trees you have a checkout out of that repository live.  They
   would want to share the same setting.
   On the other hand, some things may be truly per working tree even
   if it is tied to the same local repository.
   I am not saying it is better to tie this to $GIT_DIR not
   $GIT_WORK_TREE.  I am not necessarily saying we should support
   both.  I am only saying that we need to consider if tying only to
   $GIT_WORK_TREE makes sense (and if so, clearly communicate that
   to the end users).  I couldn't read from your patch [*1*] what
   your stance on this point.
 - The pattern defined to be case-insensitive substring would not be
   a sane general design.  I would have expected it to be fnmatch
   pattern that may match case insensitively only on case insensitive
   filesystems.
[Footnote]

*1* this is one of the reasons why I usually ignore "I'll do the doc and test if people agree it is a good idea." Often, we cannot judge if it is a good idea without these things.

Previous: Sebastian SchuberthNext: Jeff King
Message 2 of 7 in “[RFC] ident: support per-path configs by matching the path against a pattern”
  1. Sebastian SchuberthJul 10, 2015
  2. Junio C HamanoJul 10, 2015
  3. Jeff KingJul 10, 2015
  4. Jeff KingJul 10, 2015
  5. Junio C HamanoJul 10, 2015
  6. Jeff KingJul 10, 2015
  7. Junio C HamanoJul 10, 2015

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.