]> Tony Duckles's Git Repositories (git.nynim.org) - dotfiles.git/blob - bin/git-big-object-report
.bashrc: Tweak __git_ps1 colors
[dotfiles.git] / bin / git-big-object-report
1 #!/bin/sh
2 # Shows you the largest objects in your repo's pack file.
3 # Originally written for OSX by Antony Stubbs.
4 # http://stubbisms.wordpress.com/2009/07/10/git
5 #
6 # POSIX compatibility by Ryan Tomayko <r@tomayko.com>
7 set -e
8
9 # set the internal field spereator to line break, so that we can
10 # iterate easily over the verify-pack output
11 IFS=$'\n';
12
13 git_dir=$(git rev-parse --git-dir)
14
15 # list all objects including their size, sort by size, take top 10
16 objects=$(
17 git verify-pack -v "$git_dir"/objects/pack/pack-*.idx |
18 grep -v chain |
19 sort -k3nr |
20 head
21 )
22
23 printf "%7s %7s %-7s %-20s\n" SIZE PACK SHA1 LOCATION
24 for y in $objects
25 do
26 size=$((`echo $y | cut -f 5 -d ' '`/1024))
27 pack_size=$((`echo $y | cut -f 6 -d ' '`/1024))
28 sha1=$(echo $y | cut -f 1 -d ' ')
29 short=$(echo "$sha1" |cut -c1-7)
30 path=$(git rev-list --all --objects |grep $sha1 |cut -c42-)
31
32 printf "%7d %7d %-7s %-20s\n" "$size" "$pack_size" "$short" "$path"
33 done
34
35 echo "All sizes in KB. PACK = size of compressed object in pack file."