-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgit-large-objects
executable file
·42 lines (31 loc) · 1.24 KB
/
git-large-objects
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#!/bin/bash
set -e
# Shows you the largest objects in your repo's pack file.
# Written for osx.
#
# @see https://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 separator to line break, so that we can iterate easily
# over the verify-pack output
IFS=$'\n';
LINES="${1:-10}"
# 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 -n "${LINES}" \
)"
output="Size,Pack,SHA,Location"
allObjects="$(git rev-list --all --objects)"
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="$(echo "${allObjects}" | grep "$sha")"
output="${output}\n${size}k,${compressedSize},${other}"
done
echo -e "$output" | column -t -s ', '