Skip to content

Instantly share code, notes, and snippets.

@evgeny-goldin
Created January 4, 2015 22:55
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 evgeny-goldin/578d285ddb8cae59eff4 to your computer and use it in GitHub Desktop.
Save evgeny-goldin/578d285ddb8cae59eff4 to your computer and use it in GitHub Desktop.
gitsize - size diffs in two commits
# Displays size diff between two commits
# http://stackoverflow.com/a/10847242/472153
function gitsize()
{
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
}
}
# After optimizing some images ..
$ gitsize 308614f 7a29d97
-2073 content/statics/ansible.png
-2694 content/statics/aws.png
-664 content/statics/blog/barrels.jpg
-69620 content/statics/blog/orderedlistocat.png
...
total -263551
$
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment