bugGNU patch - Bugs: bug #39409, Applying context diff (with diff...


bug #39409: Applying context diff (with diff -C0) fails.

Submitted by:  None
Submitted on:  Thu 04 Jul 2013 02:28:19 AM UTC  
Category:  None Severity:  3 - Normal
Item Group:  None Status:  None
Privacy:  Public Assigned to:  None
Open/Closed:  Open

Add a New Comment (Rich Markup)

You are not logged in

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


Thu 07 May 2015 12:00:35 PM UTC, comment #4: 

It seems that you missunderstand my comment.

The gpatch sources have been modified too much and I also
modified Larry's patch sources. It seems to be hard to
compare my POSIX patch and gpatch to find the cause.

I recommend you to go back to patch-2.0-PL12u10
to find out when/how gpatch introduced the bug. You could
use the revision control to get older versions than 2.5...

Jörg Schilling <schily>
Thu 07 May 2015 11:14:04 AM UTC, comment #3: 

So you're telling me, in the GNU patch bug tracker, that other implementations of the patch algorithm don't have this bug which GNU patch has since its earliest archived version (2.5).  Fair enough, send a fix.

Andreas Gruenbacher <agruen>
Project Administrator
Thu 07 May 2015 10:21:58 AM UTC, comment #2: 

You are mistaken, the problem does not exist in the original
patch sources and it does not exist in the POSIX patch that
I created from the original sources, see:


I realized the gpatch problem two days ago when running a
regression test against my POSIX patch and using gpatch as
a reference for comparing the patched results.

Jörg Schilling <schily>
Thu 04 Jul 2013 10:28:10 AM UTC, comment #1: 

Interesting -- this bug seems to exist in all versions of patch.

Andreas Gruenbacher <agruen>
Project Administrator
Thu 04 Jul 2013 02:28:19 AM UTC, original submission:  

This occur in 2.6.1 (Ubuntu) and 2.7.1 (Cygwin).

$ echo -ne "a\nb\n" > 1.txt
$ echo -ne "a\n" > 2.txt
$ diff -C0 1.txt 2.txt > 12.patch
$ patch 1.txt 12.patch
patch: **** replacement text or line numbers mangled in hunk at line 4
$ patch -R 2.txt 12.patch
patch: **** replacement text or line numbers mangled in hunk at line 4

This doesn't occur if the order of the input is exchanged.

$ echo -ne "a\nb\n" > 1.txt
$ echo -ne "a\n" > 2.txt
$ diff -C0 2.txt 1.txt > 21.patch
$ patch 2.txt 21.patch
patching file 2.txt
$ patch -R 1.txt 21.patch
patching file 1.txt



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

Attach Files:

No files currently attached


Depends on the following items: None found

Items that depend on this one: None found


Carbon-Copy List
  • -email is unavailable- added by schily (Posted a comment)
  • -email is unavailable- added by agruen (Posted a comment)

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

    Only logged-in users can vote.




    Follow 2 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2019-07-16 agruen Assigned toagruen => None
    2013-07-04 agruen Assigned toNone => agruen

    Back to the top

    Powered by Savane 3.5