diff3 can produce quite unexpected merges
Opened this issue · 0 comments
wizzard0 commented
Repro:
var x = require("xdiff");
var util = require("util");
var o = {"k":["B","C","D","E"]};
var o2 = JSON.parse(JSON.stringify(o));
var a = {"k":["B","X","X","X","X","D","E","ERROR"]}
var b = {"k":["B","C","D","E"]}
var b2 = {"k":["B","Y","D","E"]}
var m = x.patch(o, x.diff3(a,o,b));
console.log(util.inspect(m));
var m2 = x.patch(o2, x.diff3(a,o2,b2));
console.log(util.inspect(m2));
Expected Output:
{ k: [ 'B', 'X', 'X', 'X', 'X', 'D', 'E', 'ERROR' ] }
{ k: [ 'B', 'X', 'X', 'X', 'X', 'D', 'E', 'ERROR' ] }
Actual Output:
{ k: [ 'B', 'X', 'X', 'X', 'X', 'D', 'E', 'ERROR' ] }
{ k: [ 'B', 'X', 'X', 'X', 'ERROR', 'X', 'D', 'E' ] }
(well, maybe "expected output" could be different, but inserting a "fragment" in the middle of another "fragment" is clearly wrong)