-
Notifications
You must be signed in to change notification settings - Fork 25
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
apply fails to handle diffs with files without newline or patches that remove newline at end of the file #57
Comments
Investigating more; seems to be that
|
Okay even more discovery! I did the same with GNU diff and found:
Git seems to fail on that diff style as well. |
Thanks for reporting this. If I understand your investigation, this is specifically a problem with the output of the BSD If Git supports this type of patches, I should fix this library to also accept them. If Git fails on this style of patch, I'm less inclined to add support here, but could at least see how hard it might be. I'm reasonably confident that this works correctly with Git-style patches as there were existing tests for adding a final newline and changing content without changing the final newline. You were correct that there was no test for removing the final newline, but that seems to work as expected in the current version. |
@bluekeyes it's kind of hard to replicate because the "algorithm" for producing the hunks is a bit tricky. I think git is failing to apply this same patch which I sent an email to the mailing list. It's not clear to me if it's a "bug" in Git or something purposeful. Given the prevalence of MacOS for developers (Although I daily drive NixOS :P) seems like a foot gun given that Anyways, this caused me a lot of hair pulling trying to debug; thought I'd record the info here. |
I encountered this issue via aspect-build/rules_lint#487
tl;dr; If a file is missing a newline at the end or the patch removes the newline at the end, go-gitdiff fails applying the patch with the error:
I'll push a reproduction example through a failed test, where
git
succeeds.The offending check can be found
go-gitdiff/gitdiff/apply_text.go
Line 128 in fffa3cc
The text was updated successfully, but these errors were encountered: