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 23, 2013, 08:06 UTC
Message-ID
<20130323080638.GB29768@sigill.intra.peff.net>
In-Reply-To
<878v5ezlo1.fsf@pctrast.inf.ethz.ch>
On Sat, Mar 23, 2013 at 07:15:42AM +0100, Thomas Rast wrote:
Show 21 quoted lines
> > 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:
> 
> We do, however, parse config more than once:
> 
>   $ strace git log -1 2>&1 | grep 'open.*config'
>   open("/home/thomas/.gitconfig", O_RDONLY) = 3
>   open(".git/config", O_RDONLY)           = 3
>   open("/home/thomas/.gitconfig", O_RDONLY) = 3
>   open(".git/config", O_RDONLY)           = 3
>   open("/home/thomas/.gitconfig", O_RDONLY) = 3
>   open(".git/config", O_RDONLY)           = 3
>   open("/home/thomas/.gitconfig", O_RDONLY) = 3
>   open(".git/config", O_RDONLY)           = 3
> 
> git-log might be somewhat of an extreme example, but I suspect it's at
> least twice for all commands (once for repo detection and once for
> actual parsing).  So I further suspect that the slowdown in git's own
> shellscripts (rebase) would be quite large if you actually spawned two
> extra shells every time someone says 'git rev-parse ...'.

Yeah, I knew we parsed multiple times in some cases, but I don't think it's that big a deal for a single command. But yeah, it might be noticeable for a shell script which runs lots of git commands. Still, it would only affect people who used the feature. And there is no reason the config system could not learn to cache the results across a single invocation, which would at least drop it to one shell per git command.

-Peff
Previous: Thomas Rast
Message 8 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.