delta icon indicating copy to clipboard operation
delta copied to clipboard

🚀 Integration with Graphtage or Difftastic

Open boris-petrov opened this issue 4 years ago • 17 comments

I stumbled upon Graphtage and found it a cool idea. It would be nice if delta could integrate it (and other projects like it - "semantic diffs") for specific file types. What do you think?

boris-petrov avatar Mar 07 '21 10:03 boris-petrov

Hi @boris-petrov sorry to be so slow replying to this one.

Can you be explicit about what sort of integration might make sense? It doesn't look like graphtage produces diff format AFAICS. So are you thinking of any of the following?

  1. User can do graphtage a.json b.json | delta (but how is that any better than graphtage a.json b.json)?
  2. User can do delta a.json b.json and have graphtage-like output (ok, but that is tantamount to re-implementing graphtage in Rust; delta is really a diff viewer not a diff generator)
  3. Something else?

dandavison avatar Dec 12 '21 16:12 dandavison

FYI there's a project similar to delta that does exactly this (in Rust): https://github.com/Wilfred/difftastic (not as pretty/configurable as delta though)

Maybe there's some inspiration to take here?

bew avatar Dec 12 '21 17:12 bew

FYI there's a project similar to delta that does exactly this (in Rust): https://github.com/Wilfred/difftastic

Right, difftastic looks great. I'd seen it before and meant to look more closely. One form of integration there could perhaps be difftastic emitting JSON and delta displaying it.

dandavison avatar Dec 12 '21 18:12 dandavison

Is the support for difftastic available?

marcelarie avatar Apr 19 '23 09:04 marcelarie

Is the support for difftastic available?

Not as far as I know. Looks like one path would be if a PR like this one is merged in difftastic: https://github.com/Wilfred/difftastic/pull/158

and then someone implements rendering of that JSON in delta. Delta already renders ripgrep --json output, so perhaps that implementation will be helpful when working on the difftastic JSON. (I guess in an ideal world there would be a standard format for describing token-level diffs regardless of their provenance; perhaps then difftastic and git diff --word-diff output could be the same format??)

dandavison avatar Apr 19 '23 14:04 dandavison

Ok thanks for the info. As far as I know, JSON is not the fastest to parse, right? Maybe something more raw would be better. 🤷🏽

marcelarie avatar Apr 19 '23 14:04 marcelarie

As far as I know, JSON is not the fastest to parse, right? Maybe something more raw would be better. 🤷🏽

I don't think that's an issue. Parsing JSON can be very fast. And diffing is way more expensive than any parsing could be

Guekka avatar Apr 19 '23 16:04 Guekka

The PR on difftastic to output JSON has been successfully merged: https://github.com/Wilfred/difftastic/pull/158#issuecomment-1682537893

marcelarie avatar Aug 17 '23 16:08 marcelarie

Is the support for difftastic available?

Not as far as I know. Looks like one path would be if a PR like this one is merged in difftastic: Wilfred/difftastic#158

and then someone implements rendering of that JSON in delta. Delta already renders ripgrep --json output, so perhaps that implementation will be helpful when working on the difftastic JSON. (I guess in an ideal world there would be a standard format for describing token-level diffs regardless of their provenance; perhaps then difftastic and git diff --word-diff output could be the same format??)

Hi @dandavison,

Based on the recent discussion at Delta Issue #535, it seems there might be an opportunity to address the support issue with difftastic. While I am not highly familiar with Rust, I am eager to contribute to this effort. If you could guide me on which parts of the code require modifications, I would be delighted to make a commit. Thank you for your assistance and insight.

ding-weibing avatar Jan 16 '24 06:01 ding-weibing