]> git.donarmstrong.com Git - bin.git/blob - git-hogs
add reset usb bus 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 with size first; sort, and take the top 10.
11
12 NUM="${1:-10}"
13
14 ALL_OBJECTS=`git rev-list --all --objects`
15 OBJECTS=`git cat-file --batch-check='%(objectsize:disk) %(objectsize) %(objectname) %(objecttype)' --batch-all-objects|grep blob| sort -nr | head -n $NUM`
16 IFS=$'\n'
17 OUTPUT="Size,Packed,SHA1,Name";
18 for y in $OBJECTS
19 do
20         # the size is in the 5th field; convert to IEC
21         SIZE=$(echo "$y" | cut -f 2 -d ' '|numfmt --to=iec)
22         # the compressed size is in the 6th field; convert to IEC
23         COMPRESSED_SIZE=$(echo "$y" | cut -f 1 -d ' '|numfmt --to=iec)
24         # extract the SHA
25         SHA=`echo $y | cut -f 3 -d ' '`
26         # find the objects location in the repository tree
27         OTHER=`echo "$ALL_OBJECTS" | grep "$SHA"|cut -f2 -d ' '`
28         OUTPUT="${OUTPUT}\n${SIZE},${COMPRESSED_SIZE},${SHA},${OTHER}"
29 done
30
31 echo -e $OUTPUT | column -t -s ', '