Created
June 10, 2016 17:35
-
-
Save wbotelhos/d48d0cd1b279f9995f341021537644b8 to your computer and use it in GitHub Desktop.
Git File Size Diff
This file contains hidden or 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
#!/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