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

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

From
Yaroslav Halchenko <yoh@onerussian.com>
Date
Dec 11, 2017, 21:11 UTC
Message-ID
<20171211211102.rrxqd6yscnd33efd@hopa.kiewit.dartmouth.edu>
Dear Git Gurus,

We [1] have got confused a bit about this recent addition of handling $XDG_CONFIG_HOME/git/config -- is it --global or not? ;)

According to the man git-config (v 2.15.0 in debian)
       --global
           For writing options: write to global ~/.gitconfig file rather than
           the repository .git/config, write to $XDG_CONFIG_HOME/git/config
           file if this file exists and the ~/.gitconfig file doesn’t.
           For reading options: read only from global ~/.gitconfig and from
           $XDG_CONFIG_HOME/git/config rather than from all available files.
           See also the section called “FILES”.

suggesting that $XDG_CONFIG_HOME/git/config is a part of the "--global" config space, which it is not, which is also later described in FILES:

       $(prefix)/etc/gitconfig
           System-wide configuration file.
       $XDG_CONFIG_HOME/git/config
           Second user-specific configuration file. If $XDG_CONFIG_HOME is not set or empty, $HOME/.config/git/config will be used. Any
           single-valued variable set in this file will be overwritten by whatever is in ~/.gitconfig. It is a good idea not to create this file if
           you sometimes use older versions of Git, as support for this file was added fairly recently.
       ~/.gitconfig
           User-specific configuration file. Also called "global" configuration file.
which
1. says that $XDG_CONFIG_HOME/git/config is the "Second user-specific ..."
   suggesting that it should be the one read AFTER the first user-specific...
   I guess that the first one is the ~/.gitconfig , but then why the first one
   overrides the settings of the second one ? ;)  (as described above in TFM and
   see below for an example)
2. why $XDG_CONFIG_HOME/git/config is not a part of the "global" configuration?
   I always assumed that "global" is ALL settings defined for a user,
   which are not specific to a repository.
   It is double-confusing since, as --global doc describes (and example
   below shows), git config --global --add modifies the
   $XDG_CONFIG_HOME/git/config if there is no ~/.gitconfig
   Actually the doc for --global for "reading" seems to be not correct,
   that the file is not consulted for --global (see below)
Example to show that TFM outlines precedence and --global correctly:

$> 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 $> git config --global user.xdg # so outputs nothing $> git config --global user.xdg-and-user user

$> mv .gitconfig{,.aside}
$> git config --global --add user.new value 
$> cat .config/git/config 
[user]
 xdg = xdg
 xdg-and-user = xdg
 new = value

So, is that simply a bug and $XDG_CONFIG_HOME/git/config should be consulted for --global reading and doc should be adjusted to state that it is a part of "global" config in FILES description? Or it shouldn't be --global (then writing should be fixed, and documentation adjusted to exclude it from --global) Or am I just confused? ;)

thanks in advance for the clarification!
[1]  https://github.com/datalad/datalad/pull/2019#issuecomment-350757960
-- 
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        
Next: Jonathan Nieder
Message 1 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.