Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use patches created in windows (with CRLF) in linux?I

Tags:

diff

patch

Standard linux patch hard-coded only for unix text files.

PS: I do no want convert ALL to unix and then convert result back.

like image 960
vitaly.v.ch Avatar asked Jan 16 '10 08:01

vitaly.v.ch


People also ask

How do I convert Windows line endings to Linux?

To convert from Windows to Linux line breaks you can use the tr command and simply remove the \r characters from the file. The -d option tells the tr command to delete a character, and '\r' specifies the character to delete. The input to tr is redirected from the file fileWindows.

How do I apply a Windows patch?

Highlight your project to select it. From the main menu, select menu Tools -> Apply Diff Patch. In the resulting dialog, browse to your patch file, select it, and press the Patch button.


1 Answers

Combined:

dos2unix patchfile.diff
dos2unix $(grep 'Index:' patchfile.diff | awk '{print $2}')
patch --verbose -p0 -i patchfile.diff
unix2dos $(grep 'Index:' patchfile.diff | awk '{print $2}')

The last line depends on whether you want to keep the CRLFs or not.

M.

PS. This should've been a reply to cscrimge's post. DS.

like image 153
Martin Avatar answered Dec 03 '22 10:12

Martin