git diff
is great but kinda sucks when reporting about deep keys updates in JSON files, because it only shows the last key, and not the whole object path to the updated key
$ git diff HEAD~1 -- file.json
...
- "name": "John Doe"
+ "firstName": "John",
+ "lastName": "Doe"
...
But by combining gron
with git show $rev:$path
, we can have a very pretty output that tells which keys have been updated, and it's almost valid JS!
$ diff <(git show HEAD~1:file.json | gron) <(gron file.json)
< json.users[0].owner.name = "John Doe";
---
> json.users[0].owner.firstName = "John";
> json.users[0].owner.lastName = "Doe";
I found that too elegant not to share. Have fun scripting!
Top comments (1)
That's clever.