GithubHelp home page GithubHelp logo

Comments (12)

HaleTom avatar HaleTom commented on June 9, 2024

Workaround:

Add the following alias:

[alias]
  xdsf = !"git -c interactive.diffFilter='less --tabs=4 -RFX' \"$@\" # Don't use DSF"

Usage:

git xdsf add --patch

from diff-so-fancy.

HaleTom avatar HaleTom commented on June 9, 2024

Note that the issue here is the two blank lines being added by dsf.

The cause is likely the same as the one causing issue #473.

from diff-so-fancy.

felixlinker avatar felixlinker commented on June 9, 2024

Hi! I ran into the similar issue on a binary diff (.png file). Hope that helps!

from diff-so-fancy.

scottchiefbaker avatar scottchiefbaker commented on June 9, 2024

Is this still an active with v1.4.5? I am unable to recreate the issue with the steps you provided above.

bakers@basement(~/github/diff-so-fancy)
$ git rm README.md 
rm 'README.md'

bakers@basement(~/github/diff-so-fancy)
$ git status --short
D  README.md

bakers@basement(~/github/diff-so-fancy)
$ git add --patch README.md
No changes.

from diff-so-fancy.

OJFord avatar OJFord commented on June 9, 2024

I think the deletion in OP must have been unstaged (i.e. rm not git rm) @scottchiefbaker, otherwise git add -p will always skip it, won't hit dsf.

from diff-so-fancy.

scottchiefbaker avatar scottchiefbaker commented on June 9, 2024

@OJFord attempting the same thing with rm instead of git rm still "works" for me. Git handles it appropriately and passes it to d-s-f which displays the correct content.

I'm still confused how to recreate this.

from diff-so-fancy.

felixlinker avatar felixlinker commented on June 9, 2024

@scottchiefbaker I just reproduced on master with the following commands:

rm *.png
git add -p

Output is:

felixlinker diff-so-fancy % rm *.png
felixlinker diff-so-fancy % git add -p
error: mismatched output from interactive.diffFilter
hint: Your filter must maintain a one-to-one correspondence
hint: between its input and output lines.

from diff-so-fancy.

scottchiefbaker avatar scottchiefbaker commented on June 9, 2024

I suspect this has something to do with the fact that you're deleting a binary file. I don't get this error when I delete a tracked text file. Here is the raw git diff output for a text file that has been rm'd.

diff --git a/index.html b/index.html
deleted file mode 100644
index c3ef8be..0000000
--- a/index.html
+++ /dev/null

Here is the raw git diff output for a binary file that has been rm'd.

diff --git a/image001.png b/image001.png
deleted file mode 100644
index dae0097..0000000
Binary files a/image001.png and /dev/null differ

d-s-f parses removing this binary down to three lines:

─────────────────────────────────
deleted: image001.png (binary)
─────────────────────────────────

Not sure what --patch is expecting.

from diff-so-fancy.

HaleTom avatar HaleTom commented on June 9, 2024

@scottchiefbaker git is expecting the number of lines to always be the same.

The input is 4 lines, the transformed output is 3.

To fix: add a blank like above/below the output header to keep the transformed line count the same as the input.

It's the only easily implemented sanity check that the diff filter is not doing something obviously wrong.

from diff-so-fancy.

HaleTom avatar HaleTom commented on June 9, 2024

Related issues: #35 #305 #296 #437 #473

from diff-so-fancy.

scottchiefbaker avatar scottchiefbaker commented on June 9, 2024

I'm still unable to recreate this reliably so it's hard to test. If the issue really is the 4:3 line ratio I'd expect it to pop up all over d-s-f because we do that for every file change? Is this specifically related to binary files? Or does it apply to text files as well?

A "simple" fix would be adding

print "\n";

Right after line 335 which should get you the extra line you're asking for. Try that and let me know?

from diff-so-fancy.

scottchiefbaker avatar scottchiefbaker commented on June 9, 2024

Are you calling d-s-f with --patch enabled? That is supposed to fix ratios:

# `git add --patch` requires our output to match the number of lines from the
# input. So, when patch mode is active, we print out empty lines to pad our
# output to match any lines we've consumed.

If that's not working we may need to implement the above fix wrapped in a --patch filter.

from diff-so-fancy.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.