decomp.me icon indicating copy to clipboard operation
decomp.me copied to clipboard

Three-way diffs

Open simonlindholm opened this issue 2 years ago • 6 comments

Easiest done JS-side. I guess we'll want to diff against the asm of the code that's been saved?

simonlindholm avatar Aug 26 '21 15:08 simonlindholm

Easiest done JS-side.

This would require writing the diffing algorithm in JS too, no? Right now the frontend literally just spits out the HTML that diff.py on the server gives it, with no idea about the contents.

bates64 avatar Aug 26 '21 15:08 bates64

Yep. But we can make do with a very simple algorithm:

  • line up the LHS's of the two diffs with each other
  • for chunks between lined-up parts, with diff lines that lack LHS, line both chunks up top-to-bottom
  • to check whether two RHS's are equal, just do a string comparison

I'm hoping to make the last step a bit more complex on diff.py's side so it compares branch targets in a better way; if I do I'll make sure the HTML row gets an attribute with the compare key.

simonlindholm avatar Aug 26 '21 15:08 simonlindholm

Oh, I see... you mean remember the very first diff.py result and compare against that! I assumed something a little crazier (that is, running objdump in the browser) :shipit:

I like this, sounds not-too-difficult to do.

bates64 avatar Aug 26 '21 15:08 bates64

yep

the very first diff.py result

or rather, the diff.py result of the last-saved scratch version. So you have a chance to update what you're interdiffing against, similar to how you'd restart diff.py regularly when using -b.

simonlindholm avatar Aug 26 '21 15:08 simonlindholm

Ah, I see. Comparing it against the saved version is better, yes. If we ever added a kind of version history feature it would work with that, too, which would be awesome.

bates64 avatar Aug 26 '21 15:08 bates64

The frontend supports three-way diffs already; the server just needs to return JSON with previous keys.

bates64 avatar Dec 30 '21 10:12 bates64