Skip to content

Instantly share code, notes, and snippets.

@Informatic
Last active May 20, 2023 06:57
Show Gist options
  • Save Informatic/748e3bd9bc1e70308732ece8e4cdde88 to your computer and use it in GitHub Desktop.
Save Informatic/748e3bd9bc1e70308732ece8e4cdde88 to your computer and use it in GitHub Desktop.

Advanced Recursive Diffing™

Ever needed to diff two trees of files, while doing some preprocessing on modified files? Well - we've got a solution for you. Or rather... our long friend git has.

Turns out it's perfectly legal to just use git diff --no-index on directories outside of (any) git repository. With that, we can (ab-)use built in git diff per-path/extension preprocessing feature.

Just dump attributes and config files into some/path/git/ directory, then run git diff like so:

XDG_CONFIG_HOME=$(realpath some/path) git diff --no-index /tmp/dir1 /tmp/dir2
*.json diff=json
**/lib/opkg/info/*.control diff=opkg-control
**/lib/opkg/status diff=opkg-status
[diff "json"]
textconv = jq -S .
[diff "opkg-control"]
textconv = egrep -v '^(Installed-Size|Depends):'
[diff "opkg-status"]
textconv = egrep -v '^(Installed-Size|Installed-Time|Depends):'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment