Skip to content

Instantly share code, notes, and snippets.

@wbotelhos
Created June 10, 2016 17:35
Show Gist options
  • Save wbotelhos/d48d0cd1b279f9995f341021537644b8 to your computer and use it in GitHub Desktop.
Save wbotelhos/d48d0cd1b279f9995f341021537644b8 to your computer and use it in GitHub Desktop.
Git File Size Diff
#!/bin/sh
. "$(git --exec-path)/git-sh-setup"
args=$(git rev-parse --sq "$@")
eval "git diff-tree -r $args" | {
total=0
while read A B C D M P; do
case $M in
M) bytes=$(( $(git cat-file -s $D) - $(git cat-file -s $C) )) ;;
A) bytes=$(git cat-file -s $D) ;;
D) bytes=-$(git cat-file -s $C) ;;
*)
echo >&2 warning: unhandled mode $M in \"$A $B $C $D $M $P\"
continue
;;
esac
total=$(( $total + $bytes ))
printf '%d\t%s\n' $bytes "$P"
done
echo total $total
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment