Always do not apply the SVN patch to a remote Linux machine

My typical workflow is like:

  • Check the codes from the trunk to my Windows desktop.
  • Make some corrections (but do not commit the SVN) and patch these changes using the Tortoise SVN Create Patch.
  • SSH log in to the remote Linux server and download the patch. The linux server also has an extracted HEAD channel.
  • Apply the patch on Linux Server, for example:
  [ work@remoteLinuxBox : ~ / work] patch -p0 -i ~ / work / fix.patch
 (Stripping trailing CRs from patch.)
 patching file src / java / main / myApp / view / action / test / launch / GetPeekAction.java
 Hunk # 1 FAILED at 385.
 1 out of 1 hunk FAILED - saving rejects to file src / java / main / myApp / view / action / test / launch / GetPeekAction.java.rej
 (Stripping trailing CRs from patch.)
 patching file src / java / main / myApp / view / action / test / GetAllCustomerAction.java
 Hunk # 1 FAILED at 76.
 1 out of 1 hunk FAILED - saving rejects to file src / java / main / myApp / view / action / test / GetAllCustomerAction.java.rej
 (Stripping trailing CRs from patch.)

But I always had such mistakes. I thought this was because the end of the line was different from windows and Linux, so I converted the patch using dos2unix, the warning like (Removing closing CR packages from the patch) disappeared, but the fix still failed.

There is one strange behavior: if the modification for the file occurs only on the existing line, using the patch will work. But if new lines appear, the patch will not be executed.

Does anyone know how to solve this? Many thanks

+4
source share
3 answers

Use cygwin svn diff to avoid headaches, make sure that the header of each column has only LF as the line ending instead of CR + LF. The Linux patch team doesn't work very well with hunk headers that have CR + LF line endings. I TortoiseSVN / create a patch is broken, because the patches that it creates are not cross-platform.

+4
source

I had a similar problem, and I decided that not only the line separators of the patch file, but also your working copy are important.

My working copy had Windows Line Endings lines (CR + LF), but after I converted the damaged files (in the working copy) to Unix Line Endings, the patch works! The problem is that now my file comparison tool shows that working copies of the files are different from the repository on every single line - due to different line endings. I think that eventually I will convert the entire repository to the end of the Unix line if Windows can handle them.

Hope this helps.

+3
source

You can try adding "-l -binary" to the repair command, for example:

patch -p0 -l --binary < patch.diff 
+2
source

All Articles