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

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.
Previous: Yaroslav Halchenko
Message 7 of 7 in “doc: clarify usage of XDG_CONFIG_HOME config file”
  1. doc: clarify usage of XDG_CONFIG_HOME config fileJacob Keller, Dec 12, 2017
  2. Todd ZullingerDec 12, 2017
  3. Jacob KellerDec 13, 2017
  4. Junio C HamanoDec 12, 2017
  5. Jacob KellerDec 13, 2017
  6. Yaroslav HalchenkoDec 13, 2017
  7. Junio C HamanoDec 13, 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.