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

Re: Q: rational for $XDG_CONFIG_HOME/git/config to be "non global" or just a bug?

From
Yaroslav Halchenko <yoh@onerussian.com>
Date
Dec 12, 2017, 00:48 UTC
Message-ID
<20171212004831.2sfscbrlhyokzchz@hopa.kiewit.dartmouth.edu>
In-Reply-To
<20171211225615.GC214273@aiede.mtv.corp.google.com>
On Mon, 11 Dec 2017, Jonathan Nieder wrote:
> > Example to show that TFM outlines precedence and --global correctly:
Show 7 quoted lines
> > $> grep xdg .gitconfig .config/git/config
> > .gitconfig:    xdg-and-user = user
> > .config/git/config: xdg = xdg
> > .config/git/config: xdg-and-user = xdg
> > $> git config user.xdg ; git config user.xdg-and-user
> > xdg
> > user
> I agree, this is confusing.
> Reverse engineering from source, I find that git reads the following
> files in sequence:
Show 9 quoted lines
> 	system:
> 		/etc/gitconfig
> 	global:
> 		$XDG_CONFIG_HOME/git/config
> 		$HOME/.gitconfig
> 	repo:
> 		$GIT_DIR/config
> 	commandline:
> 		options passed with -c or GIT_CONFIG_PARAMETERS
Show 5 quoted lines
> These terms (system, global, repo, etc) are accessible in code as
> current_config_scope().  I don't think there's any user-visible effect
> to $XDG_CONFIG_HOME/git/config and $HOME/.gitconfig both being global
> --- it would probably be a good cleanup to rename the scope for one of
> them.

Well, we have got at least one user/contributor now who uses $XDG_CONFIG_HOME/git/config in favor of ~/.gitconfig since it makes it easier for modular user configuration.

> I think the documentation
> 	~/.gitconfig
> 		User-specific configuration file. Also called "global"
> 		configuration file.
> should be clarified --- e.g. it could say
Show 5 quoted lines
> 	$XDG_CONFIG_HOME/git/config
> 	~/.gitconfig
> 		User-specific configuration files. Because options in
> 		these files are not specific to any repository, thes
> 		are sometimes called global configuration files.
Show 6 quoted lines
> As for "git config --global", I think the best thing would be to split
> it into two options: something like "git config --user" and "git
> config --xdg-user".  That way, it is unambiguous which configuration
> file the user intends to inspect or modify.  When a user calls "git
> config --global" and both files exist, it could warn that the command
> is ambiguous.

why ambiguous? as long as both are consistently called global, and the overloading rules are clear for reading -- nothing ambigous. The only ambigous logic would be for writing.

> Thoughts?

Well -- my main functionality concern that ATM $XDG_CONFIG_HOME/git/config is (as of 2.15.0) only --global for writing but not for regular reading (as I demonstrated in the original email)

-- 
Yaroslav O. Halchenko
Center for Open Neuroscience     http://centerforopenneuroscience.org
Dartmouth College, 419 Moore Hall, Hinman Box 6207, Hanover, NH 03755
Phone: +1 (603) 646-9834                       Fax: +1 (603) 646-1419
WWW:   http://www.linkedin.com/in/yarik        
Previous: Jonathan NiederNext: Junio C Hamano
Message 3 of 15 in “Q: rational for $XDG_CONFIG_HOME/git/config to be "non global" or just a bug?”
  1. Yaroslav HalchenkoDec 11, 2017
  2. Jonathan NiederDec 11, 2017
  3. Yaroslav HalchenkoDec 12, 2017
  4. Junio C HamanoDec 12, 2017
  5. Jacob KellerDec 12, 2017
  6. Junio C HamanoDec 12, 2017
  7. Jacob KellerDec 13, 2017
  8. Yaroslav HalchenkoDec 12, 2017
  9. Jacob KellerDec 13, 2017
  10. brian m. carlsonDec 16, 2017
  11. Jacob KellerDec 18, 2017
  12. Jeff KingDec 18, 2017
  13. Yaroslav HalchenkoDec 18, 2017
  14. Junio C HamanoDec 18, 2017
  15. Jacob KellerDec 18, 2017

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.