Hi,
Yaroslav Halchenko wrote:
> 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
I agree, this is confusing.
Reverse engineering from source, I find that git reads the following
files in sequence:
system:
/etc/gitconfig
global:
$XDG_CONFIG_HOME/git/config
$HOME/.gitconfig
repo:
$GIT_DIR/config
commandline:
options passed with -c or GIT_CONFIG_PARAMETERS
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.
I think the documentation
~/.gitconfig
User-specific configuration file. Also called "global"
configuration file.
should be clarified --- e.g. it could say
$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.
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.
Thoughts?
Thanks,
Jonathan