Skip to content

Instantly share code, notes, and snippets.

@bderickson
Created February 18, 2014 17:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bderickson/9075129 to your computer and use it in GitHub Desktop.
Save bderickson/9075129 to your computer and use it in GitHub Desktop.
#!/bin/bash
#set -x
# Shows you the largest objects in your repo's pack file.
# Written for osx.
#
# @see http://stubbisms.wordpress.com/2009/07/10/git-script-to-show-largest-pack-objects-and-trim-your-waist-line/
# @author Antony Stubbs
# set the internal field spereator to line break, so that we can iterate easily over the verify-pack output
IFS=$'\n';
# list all objects including their size, sort by size, take top 10
objects=`git verify-pack -v .git/objects/pack/pack-*.idx | grep -v chain | sort -k3nr | head`
echo "All sizes are in kB's. The pack column is the size of the object, compressed, inside the pack file."
output="size,pack,SHA,location"
for y in $objects
do
# extract the size in bytes
size=$((`echo $y | cut -f 5 -d ' '`/1024))
# extract the compressed size in bytes
compressedSize=$((`echo $y | cut -f 6 -d ' '`/1024))
# extract the SHA
sha=`echo $y | cut -f 1 -d ' '`
# find the objects location in the repository tree
other=`git rev-list --all --objects | grep $sha`
#lineBreak=`echo -e "\n"`
output="${output}\n${size},${compressedSize},${other}"
done
echo -e $output | column -t -s ', '
All sizes are in kB's. The pack column is the size of the object, compressed, inside the pack file.
size pack SHA location
69446 69406 6e0f81b51a9ef6b2eaa7d42cf9a03458a92efee5 modules/storage-centos/files/LinuxTools_QLogic-Linux-SuperInstaller-20110127-1.tgz
10910 9943 8022d756f6bd7d4369bfcd70915027af5eb6aa3f modules/hadoop_base/files/avro-tools-1.7.1.jar
10674 9738 dc2606f15853961b3d887c242aaaa57e6f7f5e50 modules/hadoop_base/files/avro-tools-1.6.3.jar
1795 1687 8fe3f4149702ca027ce582c99acfe2efb08456b6 site/shib_idp/idp/WEB-INF/lib/svnkit-1.3.0.jar
1662 1531 1ae65b08c8da38e101331b6498a2c5b14c9b4d1d modules/hadoop_hue/files/hue-plugins-2.0.0-cdh4.0.1.jar
1594 1379 f7bf1169d4290dec7103b2974b96a4fefdd4d27e site/shib_idp/idp/WEB-INF/lib/bcprov-jdk15-1.43.jar
1449 506 5180952f89b195dd916357810e929fcdb8356e80 modules/hadoop_bam/files/picard-1.76.jar
1253 1038 24041979509f0f23039389e7f98a0c0cf6b72115 site/shib_idp/idp/WEB-INF/lib/opensaml-2.3.1.jar
1024 400 13b28bb5901cee8b0269b92fbbb7f810203bcfd1 site/razor/files/ipxe.iso
757 726 7ba8ee8668938092e28a6bf06b24385d624d5d81 modules/hadoop_hue/files/mysql-connector-java-5.1.14-bin.jar
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment