fix: override delta side-by-side via --config#76
fix: override delta side-by-side via --config#76pablospe wants to merge 1 commit intodlvhdr:mainfrom
Conversation
Delta's --side-by-side flag can only enable side-by-side mode but cannot disable it when the user's gitconfig has side-by-side = true. Use a temporary gitconfig with --config that includes the user's config and overrides the side-by-side setting. Also clear the diff cache on toggle so delta re-renders with the new mode.
|
I use as my default: This is related to these issues: |
| // SetSideBySide updates the diff view mode and re-renders. | ||
| func (m *Model) SetSideBySide(sideBySide bool) tea.Cmd { | ||
| m.sideBySide = sideBySide | ||
| m.cache = make(nodeCache) |
There was a problem hiding this comment.
this needs to be rebased with your latest changes that use the cache key per mode
| if err != nil { | ||
| return "", err | ||
| } | ||
| gitconfig := filepath.Join(home, ".gitconfig") |
There was a problem hiding this comment.
hmm there are cases where this won't work.
For example, my git config sits under $XDG_CONFIG_HOME/git/config which resolves to ~/.config/git/config.
I think a more bullet proof approach would be to follow https://git-scm.com/docs/git-config#FILES.
Another approach would be to call git config --list --show-origin and look for a line relating side-by-side by delta.
There was a problem hiding this comment.
yeah, not sure about this PR, this is more a problem of delta (actually clap). I tried to solve it adding --no-* flag in delta itself:
dandavison/delta#2095
Another approach would be to call
git config --list --show-originand look for a line relating side-by-side by delta
sorry, I am not sure exactly what you mean here. Could you expand on it?
There was a problem hiding this comment.
yeah, not sure about this PR, this is more a problem of delta (actually clap). I tried to solve it adding
--no-*flag in delta itself: dandavison/delta#2095
Oh that's nice! Let's see how it goes.
sorry, I am not sure exactly what you mean here. Could you expand on it?
In order to understand where the git config file is, you can call git config --list --show-origin. For me its output is something like:
...
file:/Users/dlvhdr/.config/git/config delta.syntax-theme=tokyonight_night
file:/Users/dlvhdr/.config/git/config delta.dark=true
file:/Users/dlvhdr/.config/git/config delta.tabs=2
file:/Users/dlvhdr/.config/git/config delta.file-style=omit
file:/Users/dlvhdr/.config/git/config delta.file-decoration-style=none
file:/Users/dlvhdr/.config/git/config delta.line-numbers=true
...
You can then take the file path from the 1st column.
Summary
--side-by-sideflag can only enable side-by-side mode — there's no--no-side-by-sideto disable it. So when the user's gitconfig hasside-by-side = true, diffnav couldn't turn it off on toggle.delta --configthat includes the user's config but overridesside-by-sideto the desired value.