-
Notifications
You must be signed in to change notification settings - Fork 335
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
Deleted files cause: "error: mismatched output from interactive.diffFilter" #474
Comments
Workaround: Add the following alias:
Usage:
|
Note that the issue here is the two blank lines being added by The cause is likely the same as the one causing issue #473. |
Hi! I ran into the similar issue on a binary diff (.png file). Hope that helps! |
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. |
I think the deletion in OP must have been unstaged (i.e. |
@OJFord attempting the same thing with I'm still confused how to recreate this. |
@scottchiefbaker I just reproduced on master with the following commands:
Output is:
|
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
Here is the raw git diff output for a binary file that has been
d-s-f parses removing this binary down to three lines:
Not sure what |
@scottchiefbaker 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. |
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
Right after line 335 which should get you the extra line you're asking for. Try that and let me know? |
Are you calling d-s-f with
If that's not working we may need to implement the above fix wrapped in a |
This is happening for me on longer text files. Just upgraded 1.4.3 -> 1.4.4. Also, I am passing the
|
Tool I used removed the trailing newline from the end of package.json, and now git is complaining about diff-so-fancy. $ git diff package.json
────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
modified: package.json
────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
@@ -43,6 +43,7 @@
"@angular/platform-browser": "^19.0.0",
"@angular/platform-browser-dynamic": "^19.0.0",
"@angular/router": "^19.0.0",
+ "@angular/service-worker": "^19.0.0",
"rxjs": "~7.8.0",
"tslib": "^2.3.0",
"zone.js": "~0.15.0"
@@ -89,4 +90,4 @@
"node": "v20.18.1",
"npm": "10.8.2"
}
-}
+}
\ No newline at end of file
[core]
pager = diff-so-fancy | less --tabs=4 -RF
# Treat spaces before tabs and all kinds of trailing whitespace as an error.
# [default] trailing-space: looks for spaces at the end of a line
# [default] space-before-tab: looks for spaces before tabs at the beginning of a line
whitespace = space-before-tab,-indent-with-non-tab,trailing-space
[diff-so-fancy]
changeHunkIndicators = false
first-run = false
markEmptyLines = false
stripLeadingSymbols = false
[interactive]
diffFilter = diff-so-fancy --patch Using dsf: $ git add --patch package.json
error: mismatched output from interactive.diffFilter
hint: Your filter must maintain a one-to-one correspondence
hint: between its input and output lines. Without dsf: $ git -c interactive.diffFilter='less --tabs=4 -RFX' add --patch package.json
diff --git a/package.json b/package.json
index fe86b59..99f7b36 100644
--- a/package.json
+++ b/package.json
@@ -43,6 +43,7 @@
"@angular/platform-browser": "^19.0.0",
"@angular/platform-browser-dynamic": "^19.0.0",
"@angular/router": "^19.0.0",
+ "@angular/service-worker": "^19.0.0",
"rxjs": "~7.8.0",
"tslib": "^2.3.0",
"zone.js": "~0.15.0"
(1/2) Stage this hunk [y,n,q,a,d,j,J,g,/,e,p,?]? n
@@ -89,4 +90,4 @@
"node": "v20.18.1",
"npm": "10.8.2"
}
-}
+}
\ No newline at end of file
(2/2) Stage this hunk [y,n,q,a,d,K,g,/,e,p,?]? n When I restore the EOF newline to package.json diff-so-fancy works properly with |
It seems that the
mismatched output from interactive.diffFilter
issue has struck again in an edge case.I have a deleted, yet-to-be-staged file:
If I try to add it, I get:
Here's the original diff (obtained with
diffFilter="cat"
), and what dsf does with it:Note: if I
git add
the deleted file, agit reset --patch
will cause the same error to occur.The text was updated successfully, but these errors were encountered: