[HN Gopher] How to build a `Git diff` driver
___________________________________________________________________
How to build a `Git diff` driver
Author : zdw
Score : 125 points
Date : 2026-04-11 18:07 UTC (1 days ago)
(HTM) web link (www.jvt.me)
(TXT) w3m dump (www.jvt.me)
| gritzko wrote:
| I recently implemented a diff driver as part of git-dogs. The
| integration part Claude one-shotted.
|
| Mine is token based: https://replicated.wiki/blog/img/difflet.png
|
| The set of git tools itself, very much in development:
| https://github.com/gritzko/git-dogs
| yboris wrote:
| Related: my favorite viewer is _diff2html-cli_ which lets you see
| the diff in your browser:
|
| https://diff2html.xyz/
| JavierFlores09 wrote:
| my favorite online diff viewer so far is https://diffs.dev/,
| very straightforward. Diff2html looks cool too given it can
| work in terminal
| forrestthewoods wrote:
| Why not just use Araxis Merge or Beyond Compare?
| WalterGR wrote:
| Some alternatives to paid solutions:
|
| WinMerge is excellent, open source, and while Windows-only,
| it runs well in Wine without needing any tweaks.
|
| Kdiff is open source, cross-platform, and while I personally
| don't love it, it supports 4-pane merge, which is quite
| ergonomic and rare.
| danvk wrote:
| You might also like webdiff, which does something similar
| https://github.com/danvk/webdiff (I built this years ago and
| still use it every day.)
| Joker_vD wrote:
| I've personally settled on running diff's output into diff-
| highlight (supplied with Git!) and into ansi2html (one of them;
| there are many versions of it, and you can write one yourself
| in about 20 minutes, you only really need very few escape
| sequences handled, and then wrangle with CSS for additional 2
| hours), and calling xdg-open on the temporary file. A neat
| pipeline, all in all.
| semanticintent wrote:
| The point about textconv being sufficient in many cases is worth
| emphasizing -- the cases where you actually need a full diff
| driver are when the file has semantics that text diff destroys.
| OpenAPI specs are a good example: a field rename looks like a
| deletion + addition in text diff but is a single semantic change.
|
| I ran into the same thing building a semantic diff for a DSL
| compiler -- text diff would report noise on every whitespace or
| reorder change, but the meaningful question is "which fields
| changed type, which statements were added or removed." Once
| you're operating on the AST the signal-to-noise ratio is
| completely different.
| tarun_anand wrote:
| Is there an OSS git diff for images and multimedia?
| alkh wrote:
| I bet there might be something but you can probably create your
| own by using ImageMagick[1] and some manipulations. For ex. for
| images, I would create a temp file or use a process
| substitition + open on OSX or xdg-open on Linux. Here is a
| first post about
|
| Or you can make it even easier(cause the output is only a text)
| and simply print out the difference in metadata directly. You
| might need some other tools like ImageMagick but at least no
| shenanigans with viewing binary data as part of your diff.
|
| [1]https://stackoverflow.com/questions/5132749/diff-an-image-
| us...
| da_rob wrote:
| Yes, there is imgap: https://github.com/roblillack/imgap
|
| You can use it to create delta images for git diff but also to
| interactively compare changes via git difftool.
| faangguyindia wrote:
| Nothing beats sublime merge for this.
| pabs3 wrote:
| https://diffoscope.org/ is my favorite diff tool.
___________________________________________________________________
(page generated 2026-04-12 23:01 UTC)