-
Notifications
You must be signed in to change notification settings - Fork 402
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
Fix the empty result issue in add -p #664
Conversation
This (with the explanation) looks great @norisio, thank you! I've set the tests running on Github actions. Would you be able to add a test for the bug you've fixed? There are lots of examples in the codebase to follow, for example one possible style of test is the end-to-end type tests in test_example_diffs.rs, but if you prefer more of a unit test style that would be good too. |
OK, will try. |
I added a testcase. @dandavison Could you check the content? On master + testcase:
On this branch:
|
[32m+[m[32m println!(\"added line\");[m[41m\r[m | ||
}[m\r | ||
"; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome, thank you!
Thanks very much for this work @norisio. |
* upstream/master: Change example config in README Recognize GitHub SSH remote URLs that don't start with `git@` for hyperlinks (dandavison#668) Fix the empty result issue in add -p (dandavison#664)
Related Issues: #328, #557
Details of the issue
Current
delta
can't handle CRLF-ending diff hunks at least when used throughgit add -p
. The reason here:bytelines
library (used here) strips CRs (b'\r'
, 0x0D) as well as LFs (b'\n'
, 0x0A) when it splits bytes into lines.lines: ByteLines<BufRead>
.git
inserts some ansi control characters between CR and LF:lines
.git add -p
). Thus the rendered result will be blank (CR erases the line).What I changed
When
ingest_line
, delta strips the trailing CR.Before:
After: