How to build a `Git diff` driver

Git diff gets a glow-up: AI helpers, prettier views, and a seven-argument mystery

TLDR: A new guide shows how to plug your own compare tool into Git, explaining its quirky seven-argument call and real-world uses like comparing API files. Commenters split between letting AI wire it up, keeping it old-school, or viewing diffs in the browser—because clear, readable changes matter to everyone.

A developer finally spilled the tea on building your own Git “compare” tool—and the community immediately turned it into a spectacle. The post breaks down how Git calls an external tool with seven arguments (yes, seven), when files are new or deleted it points to /dev/null, and why quick hacks like textconv (turning files into text) won’t always cut it. There’s even a shout-out to using oasdiff to compare API blueprints and a nod to Andrew Nesbitt’s guide. Translation: more readable change views, fewer “what on earth am I looking at?” moments.

But the comments? Pure chaos and comedy. One dev bragged that “The integration part Claude one-shotted,” sparking a mini-fight about whether it’s genius or lazy to let AI wire up your tools. Another flexed a token-based approach and dropped a screenshot, while the “make it pretty” squad rallied behind diff2html to view changes in the browser. Jokes flew about Git’s “seven-argument summoning circle,” /dev/null being the “afterlife for files,” and oasdiff turning change logs into a “before/after makeover show.” The loudest opinions split three ways: purists yelling “read the man page,” pragmatists saying “ship it with AI,” and designers chanting “if it isn’t pretty, I’m not reading it.”

Key Points

  • Git can invoke external diff drivers and passes seven specific arguments to them: repo filename, before path, before SHA-1, before mode, after path, after SHA-1, and after mode.
  • For new or deleted files, Git uses /dev/null for the missing side and provides irrelevant arguments as a single period (.).
  • An external diff driver is preferred over textconv when richer output is needed or when textconv cannot adequately convert binary formats.
  • Checking the GIT_PAGER_IN_USE environment variable can help a diff tool handle both regular and Git-supplied arguments.
  • It is straightforward to wrap oasdiff as an external diff driver to compare OpenAPI specifications.

Hottest takes

"The integration part Claude one-shotted." — gritzko
"Mine is token based:" — gritzko
"my favorite viewer is diff2html-cli" — yboris
Made with <3 by @siedrix and @shesho from CDMX. Powered by Forge&Hive.