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

Re: [BUG] git config --global: doc and behaviour disagree when ~/.gitconfig and XDG config file coexist

From
Ben Knoble <ben.knoble@gmail.com>
Date
Jul 31, 2026, 00:14 UTC
Message-ID
<336EEC18-98D3-4068-8C5C-476749959814@gmail.com>
In-Reply-To
<xmqqo6fojkds.fsf@gitster.g>
Show 26 quoted lines
> Le 31 juil. 2026 à 05:35, Junio C Hamano <gitster@pobox.com> a écrit :
> 
> Nils Fahldieck <nils@fahldieck.de> writes:
> 
>> 1. The writing claim is inaccurate.
>> 
>>   The docs say XDG is used when ~/.gitconfig "doesn't exist".  The
>>   code tests READABILITY (R_OK), not existence.  A zero-byte file
>>   created by "touch ~/.gitconfig" is readable, so access_or_warn
>>   returns 0 (success), the condition is false, and XDG is silently
>>   ignored even though ~/.gitconfig is empty.
>> 
>>   The condition should be described as "when ~/.gitconfig is not
>>   readable", not "when it doesn't exist".
> 
> I do not understand this part.  If you have a file that is not even
> readable by you, it is not very useful and no better than the case
> the file did not exist.  Also, if the file exists and readable,
> between a 0-byte and one liner ~/.gitconfig there shouldn't be any
> difference in behaviour, no?
> 
> So, "when the file does not exist or even if the file exists is not
> readble, then it is not used and the other file is used instead"
> would probably be technically more correct, but I am not sure if
> such a change has much value (unless you are trying to be very
> pedantic).
My thoughts as well. A readable 0-byte file is not a counterexample to the docs; if such a file is readable then it exists, and is used as documented, no?
Show 7 quoted lines
>> 2. The reading claim is outright wrong.
>> 
>>   The docs say --global reads from BOTH files.  The code reads from
>>   ONE.  git_global_config() selects a winner and frees the other
>>   path.  There is no code path under --global that reads both files.
> 
> The documentation needs to be corrected, I think.
Agreed based on recent thread <20260720113402.0dc16abe@frustcomp.hnjs.home.arpa> (subject « git config: unintuitive behavior with - -global and - -no-includes » in case I have mis-transcribed the message ID, a necessity to maintain plain-text mail from my mobile phone, ahem).

Best, Ben

Previous: Junio C HamanoNext: Nils Fahldieck
Message 3 of 7 in “[BUG] git config --global: doc and behaviour disagree when ~/.gitconfig and XDG config file coexist”
  1. Nils FahldieckJul 30, 2026
  2. Junio C HamanoJul 30, 2026
  3. Ben KnobleJul 31, 2026
  4. Nils FahldieckJul 31, 2026
  5. Delilah Ashley WuAug 13, 2026
  6. Nils FahldieckAug 21, 2026
  7. Delilah Ashley WuAug 22, 2026

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.