bugGNU patch - Bugs: bug #28434, diff -up w/ CRLF can confuse patch

 
 

bug #28434: diff -up w/ CRLF can confuse patch

Submitted by:  None
Submitted on:  Tue 29 Dec 2009 07:03:39 PM UTC  
 
Category: NoneSeverity: 3 - Normal
Item Group: NoneStatus: Works For Me
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.

 

Thu 29 Apr 2010 05:07:08 PM UTC, comment #4:

Cannot reproduce with recent versions of patch.

Andreas Gruenbacher <agruen>
Project Administrator
Wed 30 Dec 2009 01:13:15 PM UTC, comment #3:

Which version does "patch --version" give?

Andreas Gruenbacher <agruen>
Project Administrator
Wed 30 Dec 2009 01:07:48 PM UTC, comment #2:

Actually, I cannot reproduce the problem: With diff-2.8.7, the @@ line in the patch does not have a trailing CR character, and patch-2.6 applies the patch just fine. Even when I add a trailing CR to the @@ line manually, patch-2.6 still applies the patch fine. Only when I add a trailing CR to the +++ line, applying the patch fails as you describe.

What are the contents of foo.patch in your case (cat -v)?

Andreas Gruenbacher <agruen>
Project Administrator
Tue 29 Dec 2009 07:08:22 PM UTC, comment #1:

I think this will need to be picked up by the diffutils maintainers ...

Andreas Gruenbacher <agruen>
Project Administrator
Tue 29 Dec 2009 07:03:39 PM UTC, original submission:

Version: 2.6

I've found that diff -up (show C function) can end with \r\n in hunk header which is unexpected by patch.

Reproduction:
$ echo -en 'void foo()\r\n{\r\n\r\n\r\n\r\n\r\n\r\nbar;\r\n}\r\n' > foo.1.c
$ echo -en 'void foo()\r\n{\r\n\r\n\r\n\r\n\r\n\r\nbaz;\r\n}\r\n' > foo.2.c
$ diff -up foo.1.c foo.2.c > foo.patch
$ patch < foo.patch
(Stripping trailing CRs from patch.)
patching file foo.1.c
Hunk #1 FAILED at 5.
1 out of 1 hunk FAILED -- saving rejects to file foo.1.c.rej

Attached is a patch that fixed it for me.

Thanks,
Luke

Anonymous

 

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

Attach File(s):
   
   
Comment:
   

Attached Files
file #19390:  patch-funcrlf.patch added by None (697B - application/octet-stream)

 

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)
  •  

    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 4 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Thu 29 Apr 2010 05:07:08 PM UTCagruenStatusNeed Info=>Works For Me
      Open/ClosedOpen=>Closed
    Wed 30 Dec 2009 01:07:48 PM UTCagruenStatusNone=>Need Info
    Tue 29 Dec 2009 07:03:39 PM UTCNoneAttached File-=>Added patch-funcrlf.patch, #19390

    Back to the top


    Powered by Savane 3.1-cleanup1