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

Re: feature request - have git honor nested .gitconfig files

From
Jeff King <peff@peff.net>
Date
Mar 22, 2013, 18:33 UTC
Message-ID
<20130322183306.GA32448@sigill.intra.peff.net>
In-Reply-To
<20130322182211.GD12223@google.com>
On Fri, Mar 22, 2013 at 11:22:11AM -0700, Jonathan Nieder wrote:
Show 15 quoted lines
>  * Maintaining configuration per repository to record a rather simple
>    is more complicated than ideal.  It would be easier to understand
>    the configuration if ~/.gitconfig could spell out the rule
>    explicitly:
> 
> 	[include]
> 		path = cond(starts_with($GIT_DIR, ~/dev/),
> 			    ~/.config/git/dev-config,
> 			    ~/.config/git/nondev-config)
> 
>    This means supporting an extension language in the config file.
>    It sounds hard to do right, especially considering use cases like
>    "User runs into trouble, asks a privileged sysadmin to try running
>    a command in her untrusted repository", but it is worth thinking
>    about how to do.

I'd rather not invent a new language. It will either not be featureful enough, or will end up bloated. Or both. How about something like:

  [include]
       exec = "
         case \"$GIT_DIR\" in)
           */dev/*) cat ~/.config/git/dev-config ;;
                 *) cat ~/.config/git/nondev-config ;;
          esac
       "

It involves a shell invocation, but it's not like we parse config in a tight loop. Bonus points if git provides the name of the current config file, so exec can use relative paths like:

  cat "$(dirname $GIT_CONFIG_FILE)"/dev-config
>  * The "Includes" facility is annoyingly close to being helpful.
>    An include.path setting from ~/.gitconfig cannot refer to $GIT_DIR
>    by name.

Yeah, we do not allow variable expansion at all beyond the usual path mechanisms. I think if you had $GIT_DIR, though, it would end up annoying. You do not want one file in ~/.config/git per $GIT_DIR, so you would need some way of munging $GIT_DIR into your naming scheme.

-Peff
Previous: Jonathan NiederNext: Jonathan Nieder
Message 3 of 8 in “feature request - have git honor nested .gitconfig files”
  1. Josh SharpeMar 22, 2013
  2. Jonathan NiederMar 22, 2013
  3. Jeff KingMar 22, 2013
  4. Jonathan NiederMar 23, 2013
  5. Jeff KingMar 23, 2013
  6. Junio C HamanoMar 24, 2013
  7. Thomas RastMar 23, 2013
  8. Jeff KingMar 23, 2013

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.