]> git.donarmstrong.com Git - bin.git/blob - git-hogs
add git-hogs command
[bin.git] / git-hogs
1 #!/bin/bash
2 #set -x 
3
4
5 # The original genesis for this came from
6 # http://stubbisms.wordpress.com/2009/07/10/git-script-to-show-largest-pack-objects-and-trim-your-waist-line/ Antony Stubbs
7
8 # Modified to use numfmt and only call rev-list once by Don Armstrong
9
10 # list all objects including their size, sort by size, take top 10
11
12 ALL_OBJECTS=`git rev-list --all --objects`
13 OBJECTS=`git verify-pack -v .git/objects/pack/pack-*.idx | grep -v chain | sort -k3nr | head`
14 IFS=$'\n'
15 OUTPUT="Size,Packed,SHA1,Name";
16 for y in $OBJECTS
17 do
18         # the size is in the 5th field; convert to IEC
19         SIZE=$(echo "$y" | cut -f 5 -d ' '|numfmt --to=iec)
20         # the compressed size is in the 6th field; convert to IEC
21         COMPRESSED_SIZE=$(echo "$y" | cut -f 6 -d ' '|numfmt --to=iec)
22         # extract the SHA
23         SHA=`echo $y | cut -f 1 -d ' '`
24         # find the objects location in the repository tree
25         OTHER=`echo "$ALL_OBJECTS" | grep "$SHA"`
26         OUTPUT="${OUTPUT}\n${SIZE},${COMPRESSED_SIZE},${OTHER}"
27 done
28
29 echo -e $OUTPUT | column -t -s ', '