Created
May 4, 2017 19:06
-
-
Save za3k/ba966cd443146214b5fb884c86448987 to your computer and use it in GitHub Desktop.
Print the size breakdown of git objects
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
#!/bin/sh | |
NUMFORMAT=cat | |
for program in numfmt gnumfmt | |
do | |
if which "${program}" 2>/dev/null >/dev/null | |
then | |
NUMFORMAT="${program} --to=si" | |
break | |
fi | |
done | |
echo "Size of actual bare repo (objects and packfiles): " && du -sh .git/objects .git | |
for type in tree blob tag commit | |
do | |
DISK=$(git cat-file --batch-all-objects --batch-check="%(objectname) %(objecttype) %(objectsize:disk)" | grep ${type} | cut -f 3 -d' ' | awk '{s+=$1} END {print s}' | ${NUMFORMAT}) | |
THEORY=$(git cat-file --batch-all-objects --batch-check="%(objectname) %(objecttype) %(objectsize)" | grep ${type} | cut -f 3 -d' ' | awk '{s+=$1} END {print s}' | ${NUMFORMAT}) | |
printf "Size of %+7s: %+4s (disk) %+4s (expanded)\n" ${type}s ${DISK} ${THEORY} | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment