Re: improved diff tool
- From
Johannes Schindelin <johannes.schindelin@gmx.de>
- Date
- Aug 30, 2018, 11:33 UTC
- Message-ID
- <nycvar.QRO.7.76.6.1808301324120.71@tvgsbejvaqbjf.bet>
- In-Reply-To
- <CAJmvCd1BwPNgZM+g7c6An-EESMHDOSGQe7RjkAAz36eNY3fvGA@mail.gmail.com>
Hi Piers,
On Thu, 30 Aug 2018, Piers Titus van der Torren wrote:
> I've created a diff algorithm that focuses on creating readable diffs, > see https://github.com/pierstitus/klondiff
Looks intriguing.
> The git integration as an external diff command works quite well, > though it would be nice to integrate it deeper in git, and also in > git-gui and gitk. Any way to use ext-diff from the gui tools?
Git GUI and gitk are both Tcl/Tk programs, and will need quite a bit of work to accommodate for your diff mode.
To put things into perspective: the `--color-words` mode is not integrated into Git GUI nor gitk, and it has been around for a while...
> Is there interest to incorporate this algorithm in the main git > codebase? And if so, any hints on how to proceed?
The best advice I have is to look at the `--color-words` mode. It comes with its own "consume" function that accumulates lines from the diff, then outputs them in a different way than the regular colored diff. Your mode would want to do it very similarly.
This is the accumulating part:
https://github.com/git/git/blob/v2.19.0-rc1/diff.c#L1886
and this is the display part:
https://github.com/git/git/blob/v2.19.0-rc1/diff.c#L2013
Basically, I would suggest to do a `git grep color.words` to find the places where the `--color-words` mode is special-cased, and add new special-casing for your mode. Which, BTW, I would suggest to find a catchier name for ;-)
I have not looked closely at your implementation, but I could imagine that you might want to have at least part of your algorithm step in at a much lower level: If you can use the patience diff algorithm itself for pre-processing and initial diff generation, that's great, just force XDF_PATIENCE_DIFF; Otherwise you will have to implement an alternative, similar to https://github.com/git/git/blob/v2.19.0-rc1/xdiff/xpatience.c.
Ciao, Johannes