When I try to use git add -p, I get the following error:
$ git add -p
fatal: mismatched output from interactive.diffFilter
hint: Your filter must maintain a one-to-one correspondence
hint: between its input and output lines.
I'm using delta with the following config:
$ delta --version
delta 0.4.3
$ delta --show-config
commit-style = raw
file-style = blue
hunk-header-style = syntax
minus-style = syntax 52
minus-non-emph-style = syntax 52
minus-emph-style = syntax 88
minus-empty-line-marker-style = normal 88
zero-style = syntax
plus-style = syntax black
plus-non-emph-style = syntax black
plus-emph-style = syntax 22
plus-empty-line-marker-style = normal 22
whitespace-error-style = reverse magenta
24-bit-color = false
file-added-label = 'added:'
file-modified-label = ''
file-removed-label = 'removed:'
file-renamed-label = 'renamed:'
hyperlinks = false
inspect-raw-lines = true
keep-plus-minus-markers = true
line-numbers = true
line-numbers-minus-style = red
line-numbers-zero-style = brightgreen
line-numbers-plus-style = green
line-numbers-left-style = blue
line-numbers-right-style = blue
line-numbers-left-format = '{nm:^4}⋮'
line-numbers-right-format = '{np:^4}│'
max-line-distance = 0.6
max-line-length = 512
navigate = false
paging = auto
side-by-side = false
syntax-theme = Solarized (dark)
width = 145
tabs = 4
word-diff-regex = '\w+'
In my .gitconfig are the following relevant options:
[core]
pager = delta
[delta]
commit-style = raw
file-style = blue
hunk-header-style = syntax
minus-style = syntax 52
minus-emph-style = syntax 88
zero-style = syntax normal
plus-style = syntax black
plus-emph-style = syntax 22
keep-plus-minus-markers = true
line-numbers = true
line-numbers-minus-style = red
line-numbers-zero-style = brightgreen
line-numbers-plus-style = green
whitespace-error-style = reverse magenta
minus-empty-line-marker-style = normal 88
plus-empty-line-marker-style = normal 22
[interactive]
diffFilter = delta --color-only
[color]
ui = true
Hi @Minnozz, thanks for this, very helpful. Clearly the test suite needs to be strengthened for git add -p also. I know git add -p is important, so this is probably the top priority for delta bugs right now.
Hi @dandavison, let me know if you need more information.
I looked for causes of this bug before, and
side-by-side = true
hunk-header-style = omit (only omit. I usually use this option except when git add -p)
file-style = (any option interestingly)
these options made it happened.
@Minnozz 's config can work if you remove file-style one.
I'd like to note that git add -p works here although I'm using file-style. Maybe it does not play well in combination with some other option(s) ?
For reference, my delta --show-config.
EDIT Oddly enough this config doesn't break add -p either in my environment. It contains _all_ of the options mentioned above by @ryuta69.
Thank you @Kr1ss-XD for looking. Hmm, I tried same config with you, however, it doesn't work. (core.pager = delta, and interactive.diffFilter = delta --color-only)

As picture showing,
❯ git --version
git version 2.28.0 (latest)
❯ delta --version
delta 0.4.3 (latest)
OS is MacOS Catalina 10.15.6.
Additionally, with your config, if I delete
file-style = bold 232 bright-yellow
hunk-header-style = omit normal
side-by-side = true
now it works.

That's weird.
I'm trying @Minnozz 's configuration as I'm writing. It seems if the file option is deleted, it actually works, just as you suggested.
FWIW,
$ git --version; delta --version; uname -smro
git version 2.28.0
delta 0.4.3
Linux 5.7.19-1-ck x86_64 GNU/Linux
I hope this helps chasing that bug.
If I put the file-style option in a feature category, git add -p works with the @Minnozz configuration !
[delta]
features = files
<... other options ...>
[delta "files"]
file-style = blue
cc @dandavison
EDIT The same applies to hunk-header-style = omit.
@Kr1ss-XD
Oh!
Same as hunk-header-style, and side-by-side. Moving them to features, git add -p works while usual git diff work as those options enabled!
I think
src/options/set.rs
if config::user_supplied_option("color-only", arg_matches) {
builtin_features.remove("side-by-side");
}
this is the reason why side-by-side works. I look for file-style, hunk-header-style's reasons.
Thanks a lot @Kr1ss-XD and @ryuta69 for investigating here.
I think @Kr1ss-XD's suggestion of using features to work around these issues is an excellent one for now, until we fix all the git app -p bugs.
@Kr1ss-XD I'm finding that I have to move both the file-style and hunk-header-style to a feature to make @Minnozz's config work under git add -p.
So, to be completely explicit, here is a modification of @Minnozz's config that I am finding works.
[delta]
features = meta
commit-style = raw
# file-style = blue
# hunk-header-style = syntax
minus-style = syntax 52
minus-emph-style = syntax 88
zero-style = syntax normal
plus-style = syntax black
plus-emph-style = syntax 22
keep-plus-minus-markers = true
line-numbers = true
line-numbers-minus-style = red
line-numbers-zero-style = brightgreen
line-numbers-plus-style = green
whitespace-error-style = reverse magenta
minus-empty-line-marker-style = normal 88
plus-empty-line-marker-style = normal 22
[delta "meta"]
file-style = blue
hunk-header-style = syntax
[delta "diff-filter"]
# Can leave empty, but optionally put diffFilter-only settings here
[interactive]
# I've added a --features override here to be explicit that we don't want diffFilter to use the
# features defined in the main [delta] section.
diffFilter = delta --color-only --features=diff-filter
I look for file-style, hunk-header-style's reasons.
@ryuta69 It would be awesome if you can make progress here! I'm not certain but I think
https://github.com/dandavison/delta/pull/272#discussion_r474371089 may be relevant.
[WIP]
commit_style = omit
hunk-header-decoration-style = {any option}
also triggers this bug. (It's because it removes commit hash.)
I build test, then I realized only commit-style=omit, file-style={any except raw}, and hunk-header-style={any except raw} cause this bug.
It's still WIP, but gonna send PR in few days.
[core]
pager = delta
[delta]
file-decoration-style = ul
[interactive]
diffFilter = delta --color-only
also produce this issue.
I must use this workaround replaces diffFilter = delta --color-only with diffFilter = delta --color-only --file-decoration-style=omit.
@kevinhwang91 could you confirm your delta version please?
@kevinhwang91 could you confirm your delta version please?
delta --version
delta 0.4.4
Sorry, I missed it.
I'm going to add fix, and check other options again.
Remaining bugs here should be fixed in master thanks to @ulwlu's PR #367. I'll post when it's released.
Most helpful comment
Thanks a lot @Kr1ss-XD and @ryuta69 for investigating here.
I think @Kr1ss-XD's suggestion of using features to work around these issues is an excellent one for now, until we fix all the
git app -pbugs.@Kr1ss-XD I'm finding that I have to move both the
file-styleandhunk-header-styleto a feature to make @Minnozz's config work undergit add -p.So, to be completely explicit, here is a modification of @Minnozz's config that I am finding works.