bugGNU patch - Bugs: bug #28133, patch: Cannot handle diffs with...

 
 

bug #28133: patch: Cannot handle diffs with CRLF line endings

Submitted by:  Christoph Berg <myon>
Submitted on:  Mon 30 Nov 2009 04:46:14 PM UTC  
 
Category: NoneSeverity: 3 - Normal
Item Group: NoneStatus: Fixed
Privacy: PublicAssigned to: None
Open/Closed: Closed

Add a New Comment(Rich Markup)
   

You are not logged in

Please log in, so followups can be emailed to you.

 

Tue 29 Dec 2009 07:04:20 PM UTC, comment #1:

Commit ab59a14 fixed a bug in CRLF handling for normal diffs which you are running into here: the CR stripping heuristic should not have triggered here (only the < and > lines of the patch end in CRLF).

In case the entire patch has CRLF line endings, the CR stripping heuristic will trigger, but it can be explicitly disabled using the --binary option.

I have updated the documentation of the --binary option, hopefully that's an improvement:

--binary
Write all files in binary mode, except for standard output
and /dev/tty. When reading, disable the heuristic for
transforming CRLF line endings into LF line endings. This
option is needed on POSIX systems when applying patches
generated on non-POSIX systems to non-POSIX files. (On POSIX
systems, file reads and writes never transform line endings.
On Windows, reads and writes do transform line endings by
default, and patches should be generated by diff --binary when
line endings are significant.)

Andreas Gruenbacher <agruen>
Project Administrator
Mon 30 Nov 2009 04:46:14 PM UTC, original submission:

From http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=484539 :

From: Christoph Biedl <debian.packages.hhqj@manchmal.in-ulm.de>
To: -unavailable-
Subject: patch: Cannot handle diffs with CRLF line endings
Date: Wed, 4 Jun 2008 21:20:36 +0200

Package: patch
Version: 2.5.9-5
Severity: normal

I had some trouble applying a patch that was created using diff between
two files with CRLF line endings. That process is out of my control
and cannot be changed.

As far as I can tell, the created diff has CRLF line endings like the
files; patch however drops the CR first but fails find a matching line
in the file to be patched then as the CR still exists there.

How to repeat:

$ echo -e "foo\r\nbar\r\nbaz\r\n" > rev.1
$ echo -e "foo\r\nbAr\r\nbaz\r\n" > rev.2
$ diff rev.1 rev.2 >diff
$ patch rev.1 diff
(Stripping trailing CRs from patch.)
patching file rev.1
Hunk #1 FAILED at 2.
1 out of 1 hunk FAILED -- saving rejects to file rev.1.rej
$

Workaround: Remove the CR characters from to file to be patched before
running patch (tr -d '\r'), optionally also from the diff.

This cannot be cured easily as far as I can tell from the sources. Could
you please at least document it in the BUGS section so other people can
save the time I spent hunting down the problem?

Thanks,

Christoph

Christoph Berg <myon>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach File(s):
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -unavailable- added by agruen (Posted a comment)
  • -unavailable- added by myon (Submitted the item)
  •  

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 0 encouragements so far.

    Only logged-in users can vote.

     

    Please enter the title of George Orwell's famous dystopian book (it's a date):

     

     

    Follow 2 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Tue 29 Dec 2009 07:04:20 PM UTCagruenStatusNone=>Fixed
      Open/ClosedOpen=>Closed

    Back to the top


    Powered by Savane 3.1-cleanup1