jsdiff icon indicating copy to clipboard operation
jsdiff copied to clipboard

Incorrect merge

Open doug65536 opened this issue 3 years ago • 4 comments

JSFiddle repro

What happened to def lambda... in "mine"? It ate it, right?

EDIT: link updated to fix "mine" terminology

doug65536 avatar Jan 25 '22 04:01 doug65536

I don't know if it is better or not, reduced the repro. Note that "t3" is lost in "mine".

EDIT: fixed fiddle link to not use old "/show" thing.

doug65536 avatar Jan 26 '22 01:01 doug65536

Is it because I am missing a "fuzz" algorithm when interpreting/applying the merge output, or is that t3 line intended to be in the merge result?

doug65536 avatar Feb 03 '22 12:02 doug65536

Interesting. Yeah, this is a bug.

ExplodingCabbage avatar Jan 09 '24 18:01 ExplodingCabbage

Further simplified version (which hints a bit at what's going on - presumably t3 vanishes in part because it isn't included at all in the hunk in the first patch, although that's not a complete explanation yet...):

diff = require('.');

patch1 = 'Index: bla\n' +
  '===================================================================\n' +
  '--- bla\n' +
  '+++ bla\n' +
  '@@ -4,6 +4,6 @@\n' +
  '     t4\n' +
  '         t5\n' +
  '         t6\n' +
  ' \n' +
  '-#n\n' +
  '+#?-con\n' +
  ' af\n'


patch2 = 'Index: bla\n' +
  '===================================================================\n' +
  '--- bla\n' +
  '+++ bla\n' +
  '@@ -1,9 +1,9 @@\n' +
  ' t1\n' +
  '-t2\n' +
  '+t2-mer\n' +
  ' t3\n' +
  '     t4\n' +
  '         t5\n' +
  '         t6\n' +
  ' \n' +
  '-#n\n' +
  '+#n-con\n' +
  ' af\n'

diff.merge(patch1, patch2)

ExplodingCabbage avatar Jun 26 '24 20:06 ExplodingCabbage