Image: GitHub
Why it mattersLine-based diffs miss what changed when a format carries structure. A difftool that reads the file type cuts noise in code review.
A git difftool reads two versions of a file and shows what changed. Marko Ivankovic released OmniDiff, an open-source difftool written in Rust. It reads the file type and uses a different method for each. It parses 25 programming languages with tree-sitter. It compares pictures pixel by pixel. It lists what changed inside an archive. It shows a PDF page by page.
The Show HN post was published 13 hours before this item. It has 164 points on Hacker News. The repository is ranked fourth on Trendshift's daily list on 1 November. It has 367 stars. The licence is AGPL v3, with a commercial licence offered.
What it reads
The 25 supported languages include C, C++, C#, Go, Java, JavaScript, Python, Rust and TypeScript. For code, OmniDiff builds a syntax tree with tree-sitter. It then finds the exact tokens that changed. Pictures work in PNG, JPEG, GIF, WebP, BMP, ICO and TIFF. The README says it compares them "as the eye compares them: how much changed and where". Animations are compared frame by frame.
The tool also reads font files in TrueType, OpenType, WOFF, WOFF2 and EOT. It reads cursors, PDFs, and archives in zip, tar, gzip, xz and bzip2 formats. Files with no known type fall back to a plain text diff.
OmniDiff is a terminal tool, not a window. It uses 24-bit colour when the terminal advertises it. It prints images through the kitty, sixel or iTerm2 graphics protocols. It also runs headless. That mode prints plain text or JSON for a script or a continuous integration job.
What the author measured
The author ran OmniDiff against the git history of 7,500 open-source repositories from Gentoo Linux. The benchmark holds 442,530 readable before-and-after pairs across the 25 languages. The author reports a median diff time of 4.2 milliseconds. The 97.6th percentile is 100 milliseconds. The 99th percentile is 177 milliseconds. 99.95 percent of the pairs produced a diff. 98.8 percent used a content-specific method rather than the plain text fallback.
On a code-accuracy test, the author reports 60 percent perfect matches with the --full preset. The --minimal preset reaches 69.6 percent. These are the author's figures on the author's benchmark. A reader's own files may land somewhere else.
How a team would use it
Set OmniDiff as the git difftool with its setup wizard. The repository also lists support for Jujutsu with a diff-invocation-mode = "file-by-file" line. After that, git difftool opens OmniDiff instead of the default view. A diff of a repository that holds PNG covers, OpenType fonts or signed PDFs then reads as a real diff. The old view said "binary files differ".
The honest read for a team weighing it. Tree-sitter diffs for code exist in Difftastic and Delta. A team already using one of those gets a smaller gain on code alone. The gain is the long tail: the picture, the font, the icon, the PDF, the archive. Today an engineer opens those in a second tool because git diff cannot help. The AGPL licence is the constraint a company has to read before adopting it. The commercial licence is the way around it.
Source
OmniDiff on GitHub, by Marko Ivankovic. Show HN discussion.
This item was written by an AI system from the linked source. Reveneau is responsible for what it publishes.
Get AI News in your inbox
New developer tools, model and agent releases, and how teams are actually using them to release software. Short, and only when there is something worth reading.
