bugGNU patch - Bugs: bug #51545, two different hunks can get...


bug #51545: two different hunks can get applied to the same spot

Submitted by:  Benno Schulenberg <bens>
Submitted on:  Sun 23 Jul 2017 09:20:37 AM UTC  
Category: NoneSeverity: 3 - Normal
Item Group: NoneStatus: None
Privacy: PublicAssigned 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.


Sun 23 Jul 2017 09:20:37 AM UTC, original submission:

If you have a unified diff with two hunks, and each of the hunks has the exact same context lines, and in the file that the patch gets applied to one of the outermost context lines has changed, so that one would expect the patch to apply with fuzz 1 for the first hunk, then instead both hunks get applied (after one another) to the same spot, and without any fuzz.

I can understand that the first hunk gets applied to the wrong spot (because the context there exactly matches), but then I would expect the second hunk to either fail (because it wants to use the same spot as an earlier hunk), or at least to apply with the appropriate amount of fuzz (because the context has changed after the first hunk got applied there).

See attached files for an example patch and the file that it applies to. (In this example, when applied, the fuzz for the second hunk should be 2.)

$ patch --version | head -1
GNU patch 2.7.5

Benno Schulenberg <bens>


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

Attach File(s):

Attached Files
file #41296:  GOES-WRONG.patch added by bens (610B - text/x-patch)
file #41297:  winio.c added by bens (692B - text/x-csrc)


Depends on the following items: None found

Items that depend on this one: None found


Carbon-Copy List
  • -unavailable- added by bens (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
    Sun 23 Jul 2017 09:20:37 AM UTCbensAttached File-=>Added GOES-WRONG.patch, #41296
      Attached File-=>Added winio.c, #41297

    Back to the top

    Powered by Savane 3.1-cleanup1