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

[PATCH v2 0/3] config: read both home and xdg files for --global

From
DWDelilah Ashley Wu <delilahwu@linux.microsoft.com>
Date
Aug 23, 2026, 10:28 UTC
Message-ID
<20260823-fix-config-list-global-home-and-xdg-v2-0-b29cc63f017b@microsoft.com>
In-Reply-To
<pull.1938.git.1760058849.gitgitgadget@gmail.com>
Hi all, thanks for your patience. Here's my reroll.

As reported in [1], `$HOME/.gitconfig` and `$XDG_CONFIG_HOME/git/config` are both valid global configuration locations. However, when both files exist, `git config list --global` only reads from the former location whereas `git config list` (without `--global`) reads from both. The same issue was reported for `git config get` in [2]. This inconsistency has no good justification and contradicts the documented behaviour.

Suppose that `$HOME/.gitconfig` contains:
    [home]
        config = true
and `$XDG_CONFIG_HOME/git/config` contains:
    [xdg]
        config = true
Then, listing with `--global` shows only the home config:
    $ git config list --global --show-scope --show-origin
    global  file:/Users/delilah/.gitconfig    home.config=true
and getting the XDG configuration entry with `--global` will fail:
    $ git config get --global xdg.config; echo $?
    1
Git still reads the XDG config as part of its effective configuration,
as shown by listing the configuration without `--global`:
    $ git config list --show-scope --show-origin
    global  file:/Users/delilah/.config/git/config    xdg.config=true
    global  file:/Users/delilah/.gitconfig            home.config=true

The documentation, quoted in [1] and [2], states that `--global` should read from both files, so its output should be the same as above. Here's the relevant excerpt:

Show 9 quoted lines
> OPTIONS
>     --global::
>         For writing options: write to global `~/.gitconfig` file
>         rather than the repository `.git/config`, write to
>         `$XDG_CONFIG_HOME/git/config` file if this file exists and the
>         `~/.gitconfig` file doesn't.
>
>         For reading options: read only from global `~/.gitconfig` and from
>         `$XDG_CONFIG_HOME/git/config` rather than from all available files.

To be consistent with the documentation and the behaviour without `--global`, we should read both configuration files when `--global` is passed. We do this in a few steps:

 - Patch 1 fixes slash normalisation on Windows paths. This is used for
   `--show-origin` assertions in patch 3 tests.
 - Patch 2 modifies error handling when reading configuration files.
   This is used to prevent a regression in patch 3.
 - Patch 3 reads both configuration files when `--global` is specified.

[1]: https://lore.kernel.org/git/CAFA9we-QLQRzJdGMMCPatmfrk1oHeiUu9msMRXXk1MLE5HRxBQ@mail.gmail.com/ [2]: https://lore.kernel.org/git/CAAdFe9yhBk-WecVzCTsjQ-4Z3AZAbpP+w+B076ouM3qX6d1WAg@mail.gmail.com/

Thanks again for your time! Delilah

---
Changes in v2:
 - Squash test-only patches into their corresponding implementation
   patches.
 - Reorder patches to prevent a regression from being introduced and
   then fixed in a later patch.
 - Narrow the scope of slash conversion to `xdg_config_home_for()` and
   avoid modifying `cleanup_path()`, which could've broken callers that
   do not expect normalised slashes.
 - Clarify that some tests only check the return code of a `git config`
   command; we do not care about the output.
 - Link to v1: https://patch.msgid.link/pull.1938.git.1760058849.gitgitgadget@gmail.com/
---
Delilah Ashley Wu (3):
      path: use forward slashes in XDG config on Windows
      config: let sequence require a successful file
      config: read global scope via config_sequence
 builtin/config.c     |  11 +++++
 config.c             |  76 +++++++++++++++++++++++-----------
 config.h             |   2 +
 path.c               |  16 ++++---
 t/t1300-config.sh    | 115 +++++++++++++++++++++++++++++++++++++++++++++++++++
 t/t1306-xdg-files.sh |   5 ++-
 6 files changed, 194 insertions(+), 31 deletions(-)
Range-diff versus v1:

1: d9525d954e < -: ---------- config: read both home and xdg files for --global 2: c24ed49bac < -: ---------- cleanup_path: force forward slashes on Windows 3: 51293ee827 < -: ---------- config: test home and xdg files in `list --global` 4: 26f3c46598 < -: ---------- config: read global scope via config_sequence 5: b6ab7bfd67 < -: ---------- config: keep bailing on unreadable global files -: ---------- > 1: 2fa37d8aa7 path: use forward slashes in XDG config on Windows -: ---------- > 2: d90c9ae69f config: let sequence require a successful file -: ---------- > 3: a3b5599c8d config: read global scope via config_sequence

--- base-commit: 2c78326f810173a4f3aefd8021f1e07575412481 change-id: 20260808-fix-config-list-global-home-and-xdg-9bcaac093a1b

Previous: Delilah Ashley WuNext: Delilah Ashley Wu
Message 16 of 30 in “config: read both home and xdg files for --global”
  1. 0/4 config: read both home and xdg files for --globalDelilah Ashley Wu via GitGitGadget, Oct 10, 2025
  2. 1/4 cleanup_path: force forward slashes on WindowsDelilah Ashley Wu via GitGitGadget, Oct 10, 2025
  3. Junio C HamanoNov 19, 2025
  4. 2/4 config: test home and xdg files in `list --global`Delilah Ashley Wu via GitGitGadget, Oct 10, 2025
  5. Junio C HamanoNov 19, 2025
  6. 3/4 config: read global scope via config_sequenceDelilah Ashley Wu via GitGitGadget, Oct 10, 2025
  7. Junio C HamanoNov 19, 2025
  8. 4/4 config: keep bailing on unreadable global filesDelilah Ashley Wu via GitGitGadget, Oct 10, 2025
  9. Kristoffer HaugsbakkOct 10, 2025
  10. Delilah Ashley WuNov 22, 2025
  11. Junio C HamanoJan 20, 2026
  12. Johannes SchindelinNov 17, 2025
  13. Junio C HamanoNov 18, 2025
  14. Junio C HamanoNov 19, 2025
  15. Delilah Ashley WuNov 22, 2025
  16. 0/3 config: read both home and xdg files for --globalDelilah Ashley Wu, Aug 23, 2026
  17. 2/3 config: let sequence require a successful fileDelilah Ashley Wu, Aug 23, 2026
  18. Junio C HamanoAug 26, 2026
  19. Delilah Ashley WuOct 9, 2026
  20. 1/3 path: use forward slashes in XDG config on WindowsDelilah Ashley Wu, Aug 23, 2026
  21. Junio C HamanoAug 26, 2026
  22. Delilah Ashley WuSep 10, 2026
  23. Delilah Ashley WuOct 9, 2026
  24. 3/3 config: read global scope via config_sequenceDelilah Ashley Wu, Aug 23, 2026
  25. Junio C HamanoAug 26, 2026
  26. Chris TorekAug 23, 2026
  27. Junio C HamanoAug 24, 2026
  28. 0/2 config: read both home and xdg files for --globalDelilah Ashley Wu, Oct 9, 2026
  29. 1/2 t1300: test list with missing global configDelilah Ashley Wu, Oct 9, 2026
  30. 2/2 config: read global scope via config_sequenceDelilah Ashley Wu, Oct 9, 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.