4 ms·
A third (fourth?) option worth mentioning here is difftastic[0], which uses "structural" diffing (as opposed to line diffing) for more granular diff highlightin
by knubie 3y ago
A third (fourth?) option worth mentioning here is difftastic[0], which uses "structural" diffing (as opposed to line diffing) for more granular diff highlighting.
[0] https://github.com/Wilfred/difftastic https://github.com/Wilfred/difftastic
- eviks 3y agoThis is a great approach indeed, pity it's not integrated widely enough (think it only recently got a proper structured json output other tools could use)
- m463 3y agoediff in emacs does this. Refine is what highlights the words that are different.
- ParetoOptimal 3y agoThis blog post also details using difftastic within emacs and has neat comparisons: https://shivjm.blog/better-magit-diffs/ https://shivjm.blog/better-magit-diffs/
- videlov 3y agoThank you for sharing this project! I have been searching for something like this for some time
- grotorea 3y agoI also wonder if it's possible to go beyond this project and have git itself work on the syntax level instead of pure text.
- ilyt 3y agoGit doesn't store diffs on logical level. Git operates on snapshots of trees. Commit is not "a collection of changes", it's a snapshot of a tree with attached predecessor of it. Then the another layer (which can be git, but also can be any other tool, adding custom diff tool to git is very easy) uses that to generate diffs. There is zero stopping anyone from adding contextual diffs to Git. Just ask it for content of both commits and feed it to the algorithm. Yes, git underneath stores data as diffs but they are only vaguely related to logical structure of commits
- grotorea 3y agoInteresting. Wonder if something like that can be used to make git cleverer about merges for example.
- fanf2 3y agoGit’s merge algorithm looks at three versions of the code: the two branch tips being merged, and their common ancestor. It might be better at resolving conflicts if it looked at some of the intermediate commits as well, but I don’t know of anything that does so.
- deleted 3y ago[deleted]
- ilyt 3y agoMerge part isn't pluggable like that IIRC. Would be interesting if that was given stable interface, then supposed "smart merge" tool could iterate with few ways to merge code while running tests to check which one produces least/no errors
- yencabulator 3y ago> Yes, git underneath stores data as diffs but they are only vaguely related to logical structure of commits And that's why we call that lower level compression trick "delta", not "diff".
- Izkata 3y ago> Then the another layer (which can be git, but also can be any other tool, adding custom diff tool to git is very easy) uses that to generate diffs. Linky: https://stackoverflow.com/questions/255202/how-do-i-view-git-diff-output-with-my-preferred-diff-tool-viewer https://stackoverflow.com/questions/255202/how-do-i-view-git...
- mechanicker 3y agoI feel it is best to leave git out of this - separation of concerns Let external tools evolve independently instead.
- mi_lk 3y agoonly side-by-side view, unfortunate for my unified view taste
- mega_dean 3y agoA fourth (fifth?) option worth mentioning is patdiff: https://opensource.janestreet.com/patdiff/ https://opensource.janestreet.com/patdiff/ From what I remember, it sometimes (35%) made diffs easier to read, usually (60%) made no difference, and rarely (5%) made them harder to read. I used it a few years ago though, so I don't remember specifically what the problem was. The only reason I stopped using it was because I started using magit for git diffs.
- roryokane 3y agoI agree that the patience diff algorithm generally produces better results, but you don’t need the patdiff tool for that. You can configure Git’s own diffs to use patience: https://git-scm.com/docs/git-config#Documentation/git-config.txt-codepatiencecode https://git-scm.com/docs/git-config#Documentation/git-config... I see that patdiff also provides word-level diffing. You could instead get that feature with `git diff --word-diff` or Delta (https://github.com/dandavison/delta https://github.com/dandavison/delta).
- rmwaite 3y ago`git diff --word-diff` has something close to this and it’s really nice.