More
author |
Steve Losh <steve@stevelosh.com> |
date |
Tue, 20 Sep 2022 12:53:14 -0400 |
parents |
301dff61cd7b |
children |
(none) |
#!/usr/bin/env bash
# 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
#
# Edited by sjl
# 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
objects=`git verify-pack -v .git/objects/pack/pack-*.idx | grep -P '(tree|blob|commit)'`
# echo "All sizes are in bytes. The pack column is the size of the object, compressed, inside the pack file." >&2
# echo "size,pack,SHA,location"
for y in $objects
do
# echo "$y"
# extract the size in bytes
size=`echo $y | f 3`
# extract the compressed size in bytes
compressedSize=`echo $y | f 4`
# extract the SHA
sha=`echo $y | f 1`
# find the objects location in the repository tree
loc=`git rev-list --all --objects | grep $sha | f 2`
#lineBreak=`echo -e "\n"`
echo "${size},${compressedSize},${sha},${loc}"
done