-
-
Notifications
You must be signed in to change notification settings - Fork 242
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
Issue if trying to patch file with CRLF line ending #299
Comments
Faced the same issue with LF CRLF |
same issue |
same issue. |
same issue |
same issue! |
same issue |
same issue! |
The problem is in your patch file and your editor stripping line endings. |
the issue is not with the patch file, but with the original file: if it has other than LF line endings, the as per the 1.x the code only uses |
@mamsincl Hi i have a similar problem. File in vendor have crlf line ending and my patch have lf unix style file ending. I have put --binary to vendor/cweagans/composer-patches/src/Patches.php:410 like this:
Whit this mod when run composer install i have another problem: patch: **** malformed patch at line 10: But my patch it's ok. any idea ? thanks in advance cweagans/composer-patches version 1.7.2 |
@mamsincl My original file has windows style line endings (\n\r), and I've created patch file with exactly the same line endings. And it works for me. Patch is being applied with no error. Original file still has windows line endings and content is patched properly. The error I got before was:
Or maybe I just don't understand your issue. |
Hi @agata-maksymiuk, but how do you convert ? I try convert my patch with unix2dos command, but not work. |
@mrrobotisback I did not convert. I keep the same line endings in original file and in patch. And it works.
then I did some changes in module (I used vim editor), commited them, and created patch from diff between commits, e.g.
|
Binary patching will be supported in |
I was able to get working patch after convert by unix2dos - it's require edit the patch (by mcedit for example, etc..) and remove ^M from any patch structure line that don't related to code. |
You can simplify that to this one command to make only "unified diff" header using the unix2dos your-patch.patch && awk '/^diff|^index|^---|^\+\+\+|^@@/{sub(/\r$/,"");}1' your-patch.patch > temp.patch && mv temp.patch your-patch.patch Where I had a headache with this problem today. Hopefully, the solution will help you. |
Hi cweagans,
Recently just faced with issue stated in the title.
The file I wanted to patch is using Windows standard new line characters (\r\n or CRLS). The main problem, that patch command itself stripping trailing CRs from patch so I am continuously getting different line endings error messages.
To prevent this we can use --binary switch on patch command, but as automated deployment, if I am patching your Patches class, that only will be available of the next run only ... and have to re-patch your patcher every time so the patching will failing over and over again.
Could be possible to add a settings/switch to composer.patch.json to use --binary option during patch ... something like
Thanks,
Robert Szeker
aka
Mammouth
The text was updated successfully, but these errors were encountered: