Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[git 2.17.0] fatal: mismatched output from interactive.diffFilter #296

Closed
boris-petrov opened this issue Apr 5, 2018 · 16 comments
Closed

Comments

@boris-petrov
Copy link
Contributor

I have the following in my .gitconfig:

[interactive]
	diffFilter = diff-so-fancy --patch-mode | less --tabs=4 -RFX

Doing a git add -p fails with this:

fatal: mismatched output from interactive.diffFilter
hint: Your filter must maintain a one-to-one correspondence
hint: between its input and output lines.

This didn't happen before git 2.17.0. Help! I cannot live without dsf, what do I do?!

@scottchiefbaker
Copy link
Contributor

This is related to #35. D-s-f and patch mode are not currently compatible.

@boris-petrov
Copy link
Contributor Author

But it was working (almost) fine up to now. Is there some workaround that I could use?

@scottchiefbaker
Copy link
Contributor

@boris-petrov downgrade Git? Git decided to make that change to avoid people hitting bug #35. There may be a potential solution in some code to upstream git. That was recently mentioned in #35.

I'm going to close this for now. If you have further comments about working around this I think we should move them to #35.

ahmedelgabri added a commit to ahmedelgabri/dotfiles that referenced this issue Apr 6, 2018
adamreese added a commit to adamreese/dotfiles that referenced this issue Apr 9, 2018
@OJFord
Copy link
Member

OJFord commented Apr 9, 2018

This also affects diff-highlight by the way, so it couldn't be fixed in dsf until also fixed there.

@vanniktech
Copy link

I ran into this once I added:

[diff]
	colorMoved = dimmed_zebra

and used git add -p

delphinus pushed a commit to delphinus/dotfiles that referenced this issue Apr 27, 2018
@jesstelford
Copy link

Downgrading git is no longer a viable strategy with the remote code vulnerability in git <2.17.1.

@scottchiefbaker could we re-open this issue until it's fixed?

@scottchiefbaker
Copy link
Contributor

@jesstelford I could re-open this... but the core issue is #35. I think maybe we move things over there?

I'm open to suggestions.

@jesstelford
Copy link

Apologies, I thought #35 was dead - 10months with no updates (on either side). Happy to leave the discussion there.

@scottchiefbaker
Copy link
Contributor

It's only "dead" in the sense that we can't fix anything on the d-s-f side to make it work. We need some upstream work on Git done.

@HaleTom
Copy link

HaleTom commented Jun 2, 2018

@scottchiefbaker where can we find the description of the required upstream work? Have the git devs been notified?

caleb531 added a commit to caleb531/dotfiles that referenced this issue Jun 6, 2018
caleb531 added a commit to caleb531/dotfiles that referenced this issue Jun 6, 2018
@adamtaylor13
Copy link

Even after removing this from my config I still can't use git add -p. Getting the same "fatal: mismatched output" error. Is this a larger problem with git itself? I even tried downgrading and I'm now on 2.17.1 and I cannot use git add -p at all. Pretty annoying. Any thoughts??

hxv added a commit to hxv/dotfiles that referenced this issue Jul 28, 2018
Since git version 2.17.0 diff-so-fancy does not work with interactive.diffFilter (so-fancy/diff-so-fancy#296).
arcticicestudio added a commit to arcticicestudio/igloo that referenced this issue Sep 9, 2018
Related to so-fancy/diff-so-fancy#35 and so-fancy/diff-so-fancy#296.

The reason are incompatibility problems of "diff-so-fancy" (1) with the
latest Git versions caused by changes in the diff logic.

```raw
fatal: mismatched output from interactive.diffFilter
hint: Your filter must maintain a one-to-one correspondence
hint: between its input and output lines.
```

See so-fancy/diff-so-fancy#35 and so-fancy/diff-so-fancy#296 for
details.

Note that downgrading to a compatible Git version is not an option
because versions <2.17.1 are effected by CVE-2018-11233 and and
11235 (2).

To fix this problem for interactive patch mode (3) the filter will
temporary be changed to the official diff-highlight (4) tool bundled
with Git.

```diff
[interactive]
-  diffFilter = diff-so-fancy
+  diffFilter = diff-highlight
```

References:

  (1) https://github.com/so-fancy/diff-so-fancy
  (2) https://github.com/git/git/blob/master/Documentation/RelNotes/2.17.1.txt#L7-L10
  (3) https://github.com/arcticicestudio/igloo/blob/bb19634544f91c26d66e1f7f53a6bf06210fbaaf/snowblocks/git/gitconfig#L214-L220
  (4) https://github.com/git/git/tree/master/contrib/diff-highlight

Closes GH-125
@dougpagani
Copy link

dougpagani commented Feb 3, 2019

Even after removing this from my config I still can't use git add -p. Getting the same "fatal: mismatched output" error. Is this a larger problem with git itself? I even tried downgrading and I'm now on 2.17.1 and I cannot use git add -p at all. Pretty annoying. Any thoughts??

@adamtaylor13 It's been about a half-year since you asked, but in case you still don't have a way of solving this, or in case someone else reads your comment and wishes for a quick & easy solution...

Git is trying to use diff-so-fancy as the interactiveDiffFilter. This can be frustrating to resolve, because if you configure it as a more general "filter" option, the config will still propagate down. It can come from global gitconfig (~/.gitconfig), local gitconfig (./.git/config), and in a few different filter options in different groupings.

This solution is guaranteed to work, since it will mask any other config options declared in the multiple levels: add -c "interactive.diffFilter=less as an option to your git call:

e.g.

git -c 'interactive.diffFilter=less' add -p README.md

To make things easier for you, I would suggest adding an alias or two to whatever your .shellrc file is:

alias gap="git -c 'interactive.diffFilter=less' add --patch"

# ... and other similars:
alias grp="git -c 'interactive.diffFilter=less' reset --patch"
alias gcop="git -c 'interactive.diffFilter=less' commit --patch"
alias gsp="git -c 'interactive.diffFilter=less'stash --patch"

livioso added a commit to livioso/dotfiles that referenced this issue Nov 11, 2019
arcticicestudio added a commit to arcticicestudio/igloo that referenced this issue May 9, 2020
diff-so-fancy [1] provided a way better highlighting than
diff-highlight [2], the tool that is shipped with Git.
Anyway, next to the fact that it is written in Perl and required yet
another interpreter installation, there have also been long-time
problems regarding the `fatal: mismatched output` error when running as
`interactive.diffFilter`.
In so-fancy/diff-so-fancy#296 and
so-fancy/diff-so-fancy#35 are long discussions
and some proposed workarounds, but none really worked properly.

Therefore I switched to delta [3] a while ago and the configurations
have now been tested enough on a day-by-day basis to be persisted in
igloo.
delta not only provides the same features like diff-so-fancy and other
highlighters [4] but comes with many more advantages. The highlighting
can also be styled using the same themes like bat [5] that is also
already available as snowblock [6].

The colors have been adjusted to match the Nord [7] theme.
Note that the Nord color palettes must be provided through the
terminal [8] as the 16 ANSI base colors. Some diff specific colors
have been specified as HEX tripplets. The background colors for added,
removed and modified lines are adjusted in brightness and saturation
using the `scale()` function [9] of the `color` module [10] provided by
the official Sass reference implementation written in Dart [11].

```scss
@use "sass:color";

$nord10: #5e81ac;
$nord11: #bf616a;

$minus-color: color.scale($nord11, $lightness: -28%, $saturation: -20%);
$plus-color: color.scale($nord10, $lightness: -22%, $saturation: -16%);
```

[1]: https://github.com/so-fancy/diff-so-fancy
[2]: https://github.com/git/git/tree/master/contrib/diff-highlight
[3]: https://github.com/dandavison/delta
[4]: https://github.com/dandavison/delta#features
[5]: https://github.com/sharkdp/bat
[6]: https://github.com/arcticicestudio/igloo/tree/master/snowblocks/bat
[7]: https://www.nordtheme.com
[8]: https://www.nordtheme.com/ports
[9]: https://sass-lang.com/documentation/modules/color#scale
[10]: https://sass-lang.com/documentation/modules
[11]: https://github.com/sass/dart-sass

GH-281

Co-authored-by: Sven Greb <development@svengreb.de>
arcticicestudio added a commit to arcticicestudio/igloo that referenced this issue May 9, 2020
diff-so-fancy [1] provided a way better highlighting than
diff-highlight [2], the tool that is shipped with Git.
Anyway, next to the fact that it is written in Perl and required yet
another interpreter installation, there have also been long-time
problems regarding the `fatal: mismatched output` error when running as
`interactive.diffFilter`.
In so-fancy/diff-so-fancy#296 and
so-fancy/diff-so-fancy#35 are long discussions
and some proposed workarounds, but none really worked properly.

Therefore I switched to delta [3] a while ago and the configurations
have now been tested enough on a day-by-day basis to be persisted in
igloo.
delta not only provides the same features like diff-so-fancy and other
highlighters [4] but comes with many more advantages. The highlighting
can also be styled using the same themes like bat [5] that is also
already available as snowblock [6].

The colors have been adjusted to match the Nord [7] theme.
Note that the Nord color palettes must be provided through the
terminal [8] as the 16 ANSI base colors. Some diff specific colors
have been specified as HEX triplets. The background colors for added,
removed and modified lines are adjusted in brightness and saturation
using the `scale()` function [9] of the `color` module [10] provided by
the official Sass reference implementation written in Dart [11].

```scss
@use "sass:color";

$nord10: #5e81ac;
$nord11: #bf616a;

$minus-color: color.scale($nord11, $lightness: -28%, $saturation: -20%);
$plus-color: color.scale($nord10, $lightness: -22%, $saturation: -16%);
```

[1]: https://github.com/so-fancy/diff-so-fancy
[2]: https://github.com/git/git/tree/master/contrib/diff-highlight
[3]: https://github.com/dandavison/delta
[4]: https://github.com/dandavison/delta#features
[5]: https://github.com/sharkdp/bat
[6]: https://github.com/arcticicestudio/igloo/tree/master/snowblocks/bat
[7]: https://www.nordtheme.com
[8]: https://www.nordtheme.com/ports
[9]: https://sass-lang.com/documentation/modules/color#scale
[10]: https://sass-lang.com/documentation/modules
[11]: https://github.com/sass/dart-sass

Closes GH-281

Co-authored-by: Sven Greb <development@svengreb.de>
@Pistos
Copy link

Pistos commented Mar 21, 2022

The -c workaround posted by @dougpagani can also be accomplished via ~/.gitconfig:

[alias]
  addp = -c 'interactive.diffFilter=less' add -p

@flypenguin
Copy link

so ... is this possible or not? the main page README says i can do it, yet I did and i get this error. i am confused. any info?

@tbjers
Copy link

tbjers commented Feb 1, 2023

so ... is this possible or not? the main page README says i can do it, yet I did and i get this error. i am confused. any info?

It's been working for months and months, and now it no longer works again. 😅

@vraravam
Copy link

vraravam commented Mar 27, 2023

same with me - it stopped working a few weeks ago! I have the latest git and diff-so-fancy, both installed and updated via homebrew

git version: 2.40.0
diff-so-fancy version: 1.4.2

mikesplain added a commit to mikesplain/dotfiles that referenced this issue Feb 29, 2024
dkalowsk added a commit to dkalowsk/dotfiles that referenced this issue May 10, 2024
Following the information at so-fancy/diff-so-fancy#296

I have removed the --patch flag from diff-so-fancy to
keep interactive patch additions working.  This seems to
be working locally with kitty now.

Signed-off-by: Dan Kalowsky <dank@deadmime.org>
dkalowsk added a commit to dkalowsk/dotfiles that referenced this issue Oct 22, 2024
Following the information at so-fancy/diff-so-fancy#296

I have removed the --patch flag from diff-so-fancy to
keep interactive patch additions working.  This seems to
be working locally with kitty now.

Signed-off-by: Dan Kalowsky <dank@deadmime.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests