Source

git-pastiche / bin / git-stats

Diff from to

File bin/git-stats

 NUMBER_OF_FILES=`git ls-files | wc -l | tr -d ' '`
 NUMBER_OF_CONTRIBUTORS=`git shortlog -s -n | wc -l | tr -d ' '`
 AGE=`git log --reverse --format='%cr' | head -n 1`
-
+REPO_SIZE=`du -hs $(git rev-parse --git-dir) | awk '{print $1}'` # count-objects has size-pack but that _requires_ the repository to be packed
 
 # %'.3f\n
-printf "Number of contributors: %'12.d\n" $NUMBER_OF_CONTRIBUTORS
-printf "Number of commits     : %'12.d\n" $NUMBER_OF_COMMITS
-printf "Number of objects     : %'12.d\n" $NUMBER_OF_OBJECTS
-printf "Number of files       : %'12.d\n" $NUMBER_OF_FILES
-printf "First commit          : %12s\n" "$AGE"
+printf "Repository size (approx): %12s\n"   "${REPO_SIZE}"
+printf "Number of contributors  : %'12.d\n" $NUMBER_OF_CONTRIBUTORS
+printf "Number of commits       : %'12.d\n" $NUMBER_OF_COMMITS
+printf "Number of objects       : %'12.d\n" $NUMBER_OF_OBJECTS
+printf "Number of files         : %'12.d\n" $NUMBER_OF_FILES
+printf "First commit            : %12s\n"   "${AGE}"