This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Patch, diff, and line-endings


Hello David,

* On Tue, Mar 16, 2010 at 03:15:13PM -0400 David Eisner wrote:

> I'm running into a problem when applying patches.  Here's a toy
> example.  I have a file, test.txt, with a one line change. I use diff
> -u to generate a patch, and then I use patch to apply it.
> 
> With unix-style line-endings (\n), everything works fine:
[...]
 
> But with dos-style line-endings (\r\n), the patch fails:
> 
> $ file {a,b}/test.txt
> a/test.txt: ASCII text, with CRLF line terminators
> b/test.txt: ASCII text, with CRLF line terminators
[...]
 
> Shouldn't this work, regardless of the line-ending type?

No: patch is very picky here. From my experience, you will observe the
same behaviour on a Linux machine.

In a project I am involved, we were using diffs frequently to send in
changes. (Only recently, we changed to something more reasonable.) We
always had this problem from DOS/Windows users.

 
> I repeated the same experiment on a Solaris 10 box with GNU diff 2.8.1
> and GNU patch 2.5.4, and it worked fine, with both unix- and dos-style
> line endings.

Now, this is surprising to me, as I have seen the same exact problem on
Linux. AFAIR, this is a problem of patch itself. Perhaps, Solaris 10
does something differently, hiding the CRLF from patch?

BTW: In the project mentioned above, we always solved the issue with
     dos2unix.

Best regards,
Spiro.

-- 
Spiro R. Trikaliotis                              http://opencbm.sf.net/
http://www.trikaliotis.net/                     http://www.viceteam.org/

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]