bugGNU patch - Bugs: bug #42922, patch --merge=merge produces...

 
 

bug #42922: patch --merge=merge produces incorrect output

Submitter:  None
Submitted:  Wed 06 Aug 2014 01:07:33 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
   

Tue 10 Mar 2015 08:03:07 PM UTC, comment #1: 

What's going on here becomes more clear in --merge=diff3 mode:


A
B
<<<<<<<
|||||||
D
=======
Y
D
>>>>>>>
C
C
Y
D
C
E


Here, patch is saying that it didn't find D. In --merge=merge mode (the default), the expected output would be:


A
B
<<<<<<<
=======
Y
>>>>>>>
C
C
Y
D
C
E


Andreas Gruenbacher <agruen>
Group administrator
Wed 06 Aug 2014 01:07:33 AM UTC, original submission:  

I believe the output of patch --merge=merge is incorrect in this test case (which I've derived from some actual source code I was working on, so it's not a theoretical bug):

patch:

diff -u B/test9 C/test9
--- B/test9         2014-07-27 15:51:36.549046175 +0000
+++ C/test9        2014-07-27 15:52:11.005604882 +0000
@@ -0,5 +0,6 @@
 A
 B
+Y
 D
 C
 E


test file:

A
B
C
C
Y
D
C
E


The output is

A
B
<<<<<<<
=======
Y
D
>>>>>>>
C
C
Y
D
C
E


But reading only the "new" part of that gives us two "D" lines, even though there's only one in the original file and the patch file doesn't add any! In practice, this problem happens with a closing brace rather than "D", and gives me unbalanced C statements even though the original file and the patch are both balanced.


I might be misunderstanding fundamentally how patch is supposed to work in this situation, but I don't think I am; I've been investigating and trying to understand the code in merge.c, but I'm not quite there yet.

Anonymous

 

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

Attach Files:
   
   
Comment:
   

Attached Files
file #31847:  test added by None (17B - application/octet-stream)
file #31848:  test.diff added by None (154B - text/x-patch)

 

Depends on the following items: None found

Items that depend on this one: None found

 

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

    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
    2014-08-06 None Attached File- Added test, #31847
        Attached File- Added test.diff, #31848

    Back to the top

    Powered by Savane 3.13-f8d8.
    Corresponding source code