Skip to content

Instantly share code, notes, and snippets.

@Deadlyelder
Last active September 13, 2018 09:26
Show Gist options
  • Save Deadlyelder/37c4e1682f61e8bf0809b3e07acc97f8 to your computer and use it in GitHub Desktop.
Save Deadlyelder/37c4e1682f61e8bf0809b3e07acc97f8 to your computer and use it in GitHub Desktop.
Dirty script to get diff in more systematic manner (without noise) for AST
git diff <hash-commit-1>:<fillename> <hash-commit-1>:<filename> | gawk 'match($0,"^@@ -([0-9]+),[0-9]+ [+]([0-9]+),[0-9]+ @@",a){left=a[1];right=a[2];next}
/^(---|\+\+\+|[^-+ ])/{print;next};\
{line=substr($0,2)};\
/^-/{print "-" left++ ":" line;next};\
/^[+]/{print "+" right++ ":" line;next};\
{print "(" left++ "," right++ "):"line}' | grep -v '^+++' | grep -v '^---' | grep -v 'diff' | grep -v 'index'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment