-
-
Save evgeny-goldin/578d285ddb8cae59eff4 to your computer and use it in GitHub Desktop.
gitsize - size diffs in two commits
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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