delta icon indicating copy to clipboard operation
delta copied to clipboard

🐛 $XDG_CONFIG_HOME/git/config is not checked

Open flrgh opened this issue 10 months ago • 3 comments

Hiya 👋

I was trying out delta today and had a confusing debug session as I attempted to figure out why none of the [delta] settings in my git config seemed to be working. Lo and behold, the issue was that delta only reads from ~/.gitconfig, whereas I use $XDG_CONFIG_HOME/git/config:

$ grep -A1 -F '[delta]' $XDG_CONFIG_HOME/git/config
[delta]
        line-numbers = true

$ git config list | grep delta.line-numbers
delta.line-numbers=true

$ delta --show-config | grep line-numbers
    line-numbers                  = false

From reading more through the docs I understand there are several ways to overcome this limitation (i.e. passing --config /path/to/file to delta). However, given that "you can configure it the same way you configure git" is part of the elevator pitch for delta, I think supporting $XDG_CONFIG_HOME/git/config would be worthwhile, as this is officially supported by git itself.

That's all. Thanks for creating cool things in your spare time and giving them away for free :)

flrgh avatar Mar 07 '25 18:03 flrgh

Thanks @flrgh! I believe this should be an easy fix to make. We use the Rust bindings to libgit2, and they have https://docs.rs/git2/latest/git2/struct.Config.html#method.find_xdg

This is one/the relevant section of delta code in case anyone else would like to take this on: https://github.com/dandavison/delta/blob/main/src/cli.rs#L1339

dandavison avatar Mar 07 '25 18:03 dandavison

Hello @flrgh,

I read your issue and try to reproduce it on MacOS and Ubuntu. But delta --show-config give me the expected result.

Where $XDG_CONFIG_HOME is defined on your computer?

Can you explain how can I reproduce the issue?

Best regards,

yruellan avatar Apr 25 '25 16:04 yruellan

Hello, i believe I've encountered the same issue.

I'm running NixOS and made a wrapper around git (which essentially sets the GIT_CONFIG_GLOBAL to a file in the nix store)

Within this file i have the options:

# ...

[delta]
  navigate = true
  line-numbers = true
  side-by-side = true

# ...

Running $ git config list yields:

...
core.pager=delta
interactive.difffilter=delta --color-only
delta.navigate=true
delta.line-numbers=true
delta.side-by-side=true
...

Yet when running git diff, it displays using delta but without the options.

Note that setting the following fixes it/works

[core]
  pager = delta --side-by-side

Can you explain how can I reproduce the issue?

@yruellan Essentially just make a separate gitconfig file with the contents:

[core]
  pager = delta

[delta]
  navigate = true
  line-numbers = true
  side-by-side = true

Then you can set GIT_CONFIG_GLOBAL="/path/to/gitconfig" and you should be able to replicate the issue

Daniel-De-Dev avatar Nov 15 '25 16:11 Daniel-De-Dev