Weblog entry #456 for simonw

Cygwin "patch" feature
Posted by simonw on Mon 14 May 2012 at 15:33
Tags: none.
Trying to merge trivial set of changes using Cygwin got nonsensical difference as if the white space was changed.

Poked around and came to the conclusion "patch" was broken on Cygwin, and a quick Google gave:

http://cygwin.com/ml/cygwin/2010-03/msg00559.html

So two files with the same DOS line ending convention, diff fine. Applying that diff to a third file with the same line endings always fails with "Hunk failed" for each hunk. Forcing it is seems to change the line ending convention of similar.

I know my brain wouldn't handle trying to patch patch for this edge case, but annoying.

 

Comments on this Entry

Posted by mcortese (85.158.xx.xx) on Tue 15 May 2012 at 17:53
[ Send Message | View Weblogs ]
I think the issue is both with diff, which generates hybrid patch files (mixing LF-terminated and CRLF-terminated lines), and then with patch, which fails to handle them. Purely DOS-style patch files (with only CRLF-terminated lines) seem to work flawlessly.

The easiest solution is to sanitize the patch file through dos2unix (or even unix2dos if you wish) before feeding it to patch:

cat my.patch | dos2unix | patch -p1

[ Parent | Reply to this comment ]