Skip to content

Instantly share code, notes, and snippets.

@Zash
Last active March 1, 2024 12:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Zash/69bea1c814b503d6ac6f9865927f0d00 to your computer and use it in GitHub Desktop.
Save Zash/69bea1c814b503d6ac6f9865927f0d00 to your computer and use it in GitHub Desktop.
git-diff json
#!/bin/bash
set -euo pipefail
case $# in
1)
diff -u --color --label="$1 @ HEAD" --label="$1" <(git show "HEAD:$1" | yq4 -oj | gron) <(yq4 -oj "$1" | gron)
;;
2)
diff -u --color --label="$1 @ $2^" --label="$1 @ $2" <(git show "$2^:$1" | yq4 -oj | gron) <(git show "$2:$1" | yq4 -oj | gron)
;;
3)
diff -u --color --label="$1 @ $2" --label="$1 @ $3" <(git show "$2:$1" | yq4 -oj | gron) <(git show "${3}:$1" | yq4 -oj | gron)
;;
esac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment