Re: [PATCH] doc: clarify usage of XDG_CONFIG_HOME config file
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Dec 13, 2017, 19:57 UTC
- Message-ID
- <xmqqmv2mwgd7.fsf@gitster.mtv.corp.google.com>
- In-Reply-To
- <20171213142334.oy2uvkamho4whspj@hopa.kiewit.dartmouth.edu>
Yaroslav Halchenko <yoh@onerussian.com> writes:
Show 5 quoted lines
> It always read it for non--global > ... > and it doesn't read it for --global > ... > unless ~/.gitconfig is missing
Yes, this dates back to 21cf3227 ("config: read (but not write) from $XDG_CONFIG_HOME/git/config file", 2012-06-22), around the time back when we added support to use xdg locations and doing so without breaking existing users.
Taken together with a later commit in the same series 0e8593dc ("config: write to $XDG_CONFIG_HOME/git/config file when appropriate", 2012-06-22), which says:
config: write to $XDG_CONFIG_HOME/git/config file when appropriate
Teach git to write to $XDG_CONFIG_HOME/git/config if
- it already exists,
- $HOME/.gitconfig file doesn't, and
- The --global option is used.
Otherwise, write to $HOME/.gitconfig when the --global option is
given, as before.
If the user doesn't create $XDG_CONFIG_HOME/git/config, there is
absolutely no change. Users can use this new file only if they want.
If $XDG_CONFIG_HOME is either not set or empty, $HOME/.config/git/config
will be used.
Advice for users who often come back to an old version of Git: you
shouldn't create this file.the plan is to have either one of these and not both at the same time. A user who wants to live in xdg world (and wants to avoid cluttering $HOME with .many-files) can do so by creating an empty one there, and all writes from there on go to the xdg world; as there will no $HOME/.gitconfig created, the read side attempting to read from it does not matter. Other users get $HOME/.gitconfig when running "config --global" to write for the first time, or users who have been using Git from olden days already have $HOME/.gitconfig, and no write goes to xdg world, so again the read side attempting to read from there does not matter, either.
Perhaps a doc update needs to clarify these.
Thanks.