# How to build a \`git diff\` driver

DevFeed: [How to build a \`git diff\` driver](<https://devfeed.tech/articles/how-to-build-a-git-diff-driver-53075.md>)

Original publisher: [Read original article](<https://www.jvt.me/posts/2026/04/11/how-git-diff-driver/>)

Author: Jamie Tanna

Published: 2026-04-11T11:32:10Z

Content type: tutorial

Language: en

Sources: [articles on Jamie Tanna | Software Engineer](<https://devfeed.tech/sources/articles-on-jamie-tanna-software-engineer.md>)

Topics: [Git](<https://devfeed.tech/topics/git.md>), [implementation](<https://devfeed.tech/topics/implementation.md>), [OpenAPI Specification](<https://devfeed.tech/topics/openapi.md>)

Tags: [api](<https://devfeed.tech/tags/api.md>), [blogumentation](<https://devfeed.tech/tags/blogumentation.md>), [build](<https://devfeed.tech/tags/build.md>), [git](<https://devfeed.tech/tags/git.md>), [hash](<https://devfeed.tech/tags/hash.md>), [how-to](<https://devfeed.tech/tags/how-to.md>), [implementation](<https://devfeed.tech/tags/implementation.md>), [openapi](<https://devfeed.tech/tags/openapi.md>)

## AI overview

A tutorial on creating an external command for Git diff drivers, including the arguments Git passes to the command for updated, added, and deleted files. It also discusses using a wrapper script to compare OpenAPI specifications and potential caching with file checksums.

## Source excerpt

Something I've been meaning to write about since November 2024 is how to create an external command for diffing between files with git diff. I found that while I was implementing renovate-packagedata-diff that there seemed to be a lack of documentation around how to do it, so it would be worthwhile me blogging about it. (I've since found that there is some documentation in the Git Diffs man page, but it wasn't exactly well discoverable) It's been at the back of my mind as a TODO for some time, and then I was nudged about it fairly recently by Andrew Nesbitt's good post on Git Diff Drivers, and this week looking at diffing OpenAPI specs with oasdiff. I thought I'd use this as an opportunity for blogging about how this works, as well as adding a separate for oasdiff as a diff driver. Note that this is a case where we want to expose more information in our output, and can't rely on the textconv method to convert a (binary) file to a more diff-able textual format. In a lot of cases, using textconv is likely sufficient! What arguments do we need to handle? Although many tools would work out-of-the-box if they expect to be run as tool [before] [after], git diff passes 7 arguments to the external tool it's calling. Although surprising, this does provide some richer data that is useful to have. To give a more "worked example", let's look at what this looks like for updating an existing file, or adding/deleting a file: # newlines added for readability purpose only # when an existing file is updated renovate-packagedata-diff renovate/github-co-cddo-api-catalogue.json # 1: filename in the repo /tmp/git-blob-shryRa/github-co-cddo-api-catalogue.json # 2: "before" f0a1311ae439fff36f994a3be5d5a7eb7d7a34dc # 3: SHA-1 hash of the "before" file 100644 # 4: octal mode of the "before" file /tmp/git-blob-y2mrZp/github-co-cddo-api-catalogue.json # 5: "after" e39975894a72f706e6a59bccf31120ffaa219ff3 # 6: SHA-1 hash of the "after" file 100644 # 7: octal mode of the "after" file # when a ne