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

 
 

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

Submitter:  Benno Schulenberg <bens>
Submitted:  Sun 23 Jul 2017 09:20:37 AM UTC
   
 
Category:  None Severity:  3 - Normal
Item Group:  None Status:  None
Privacy:  Public Assigned to:  None
Open/Closed:  Open
* Mandatory Fields

Add a New Comment Rich Markup
   

Fri 04 May 2018 07:05:34 AM UTC, comment #3: 

I agree that being able to limit the offset, the same way we are allowed to limit the fuzz, could be useful in specific cases, however this is unrelated to this bug report.

Jean Delvare <khali>
Thu 03 May 2018 07:01:16 PM UTC, comment #2: 

True -- the fix was confirmed on the mailing list: http://lists.gnu.org/archive/html/bug-patch/2017-09/msg00007.html.

(It would be good if bug-fixing commits referenced the relevant bug report.)

A still better fix would be if one could nudge 'patch' toward doing the right thing.  As the above email suggests: """Would it be possible to tell 'patch' to limit the area in which it will search for a context match?  So that the user could do something like --within=20, which would make 'patch' accept an offset of at most twenty lines?"""

Benno Schulenberg <bens>
Thu 03 May 2018 12:27:28 PM UTC, comment #1: 

I believe this was fixed by:

http://git.savannah.gnu.org/cgit/patch.git/commit/?id=00947f4111fbb388852e0626ba7bd1aef5d53cd9

Can you test again with patch v2.7.6?

Jean Delvare <khali>
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 Files:
   
   
Comment:
   

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
  • -email is unavailable- added by khali (Posted a comment)
  • -email is unavailable- added by bens (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only logged-in users can vote.

     

    Follow 2 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2017-07-23 bens Attached File- Added GOES-WRONG.patch, #41296
        Attached File- Added winio.c, #41297

    Back to the top

    Powered by Savane 3.13-3230.
    Corresponding source code