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

Re: Git --file doesn't override $HOME in version 1.8.1.2

From
Jeff King <peff@peff.net>
Date
Jul 9, 2013, 19:24 UTC
Message-ID
<20130709192455.GC5153@sigill.intra.peff.net>
In-Reply-To
<87mwpweywu.fsf@linux-k42r.v.cablecom.net>
On Tue, Jul 09, 2013 at 01:49:21PM +0200, Thomas Rast wrote:
Show 13 quoted lines
> Rather, it's very strange that 'git config --file foo' tries to look at
> any config file other than 'foo'.  In a git repo:
> 
>   $ strace git config --file fooconfig test.var 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("fooconfig", O_RDONLY)             = 3
> 
> I haven't looked into the code yet.  Probably it's simply following the
> usual code paths to discover a repo and read its config.  However, with
> the --file option, it shouldn't.

I'm not so sure. It is (in theory) OK to read the usual config files to find out _how_ git-config should behave, but then return results from a specific file. The former should read the "normal" files, and the latter should read whatever is specified by the options ("--file", a specific level like "--global", or the usual set of files).

There are probably not many config options that can affect git-config's behavior. The few I can think of are:

  1. core.editor should affect "git config --edit"
  2. pager.config would auto-start a pager. I am not sure if that is a
     sane thing to do or not.
  3. In theory you could have advice.* affect git-config, but I do not
     think any currently do.
  4. Currently git-config does not read objects, but there are patches
     proposed to do so. In that case, things like core.packedGitWindowSize
     might be important.

So I think you could probably drop the config parsing, special-case (1), and ignore (2) as silly. But I think (3) and (4) show that it isn't the right thing to do; you will never know which config options affect git-config's behavior in the future.

The real issue here is not the "extra" normal config parsing; it is that the normal parsing does not work in some cases. And that has already been fixed by Jonathan's 4698c8f (config: allow inaccessible configuration under $HOME, 2013-04-12).

-Peff
Previous: Thomas RastNext: Junio C Hamano
Message 3 of 5 in “Git --file doesn't override $HOME in version 1.8.1.2”
  1. Sarajärvi TonyJul 9, 2013
  2. Thomas RastJul 9, 2013
  3. Jeff KingJul 9, 2013
  4. Junio C HamanoJul 9, 2013
  5. Sarajärvi TonyJul 9, 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.