Re: [BUG] git config --global: doc and behaviour disagree when ~/.gitconfig and XDG config file coexist
Junio C Hamano <[email protected]> Thu, 30 Jul 2026 13:24:47 -0700
| Newsgroups | org.kernel.vger.git |
|---|---|
| Message-ID | <[email protected]> |
Nils Fahldieck <[email protected]> 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). > 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.