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