Enable the wincred credential helper by default for Windows users.
[msysgit.git] / bin / what-made-this-repo-so-large.sh
blob02d7f6b1c3d3d9e02d6cd83c20c3eadd30569f4f
1 #!/bin/sh
3 # This script tries to find out what made your repository so large.
4 # It sorts the loose and packed objects by size (for packed objects, we look
5 # at the size in the pack) and shows the largest ten.
7 die () {
8 echo "$*" >&2
9 exit 1
12 identify_object () {
13 LINES="$(git log --root --raw --abbrev=40 --all --format="commit %H" |
14 grep -e '^commit' -e "^:[^ ]* [^ ]* [^ ]* $1" |
15 grep -m1 -B1 "^:[^ ]* [^ ]* [^ ]* $1")"
16 if test -n "$LINES"
17 then
18 COMMIT="$(git name-rev $(echo "$LINES" |
19 sed -n 's/commit //p') |
20 sed 's/^[^ ]* //')"
21 PATH="$(echo "$LINES" | sed -n 's/^.* //p')"
22 printf "'%s:%s'" $COMMIT "$PATH"
26 N=10
27 test $# -gt 0 && N=$1
29 GIT_DIR="$(git rev-parse --git-dir)" || die "No repository found"
30 OBJECT_LIST="$( (cd "$GIT_DIR" &&
31 ls -l objects/??/* |
32 sed 's/^\([^ ]* *\)\{4\}\([^ ]*\).* objects\/\(..\)\/\(.\{38\}\)$/\2 \3\4/' &&
33 for pack in "$(ls objects/pack/*.pack 2> /dev/null)"
35 git verify-pack -v "$pack" 2>&1 |
36 sed -n 's/^\([^ ]\{40\}\) *[^ ]* *[^ ]* *\([1-9][0-9]*\).*$/\2 \1/p'
37 done) |
38 sort -n -r |
39 uniq |
40 head -n "$N")"
42 echo "$OBJECT_LIST" |
43 while read size sha1
45 echo $size $sha1 "$(identify_object $sha1)"
46 done