git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* Q: rational for $XDG_CONFIG_HOME/git/config to be "non global" or just a bug?
@ 2017-12-11 21:11 Yaroslav Halchenko
  2017-12-11 22:56 ` Jonathan Nieder
  0 siblings, 1 reply; 15+ messages in thread
From: Yaroslav Halchenko @ 2017-12-11 21:11 UTC (permalink / raw)
  To: git@vger.kernel.org; +Cc: kyle

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        

^ permalink raw reply	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2017-12-18 19:57 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-12-11 21:11 Q: rational for $XDG_CONFIG_HOME/git/config to be "non global" or just a bug? Yaroslav Halchenko
2017-12-11 22:56 ` Jonathan Nieder
2017-12-12  0:48   ` Yaroslav Halchenko
2017-12-12  1:05   ` Junio C Hamano
2017-12-12  9:36     ` Jacob Keller
2017-12-12 19:36       ` Junio C Hamano
2017-12-13  5:35         ` Jacob Keller
2017-12-12 14:13     ` Yaroslav Halchenko
2017-12-13  5:35       ` Jacob Keller
2017-12-16 22:01     ` brian m. carlson
2017-12-18  4:03       ` Jacob Keller
2017-12-18  6:40         ` Jeff King
2017-12-18 14:21           ` Yaroslav Halchenko
2017-12-18 16:55             ` Junio C Hamano
2017-12-18 19:56           ` Jacob Keller

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).