blob: 26eafb124f769818f8d3ad7f1d98626decf50df4 (
plain) (
blame)
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
|
# Scrub and pack Git repositories
# Iterate through given directories; default to the current one
for arg in "${@:-.}" ; do (
# Note the "exit" calls here in lieu of "continue" are deliberate; we're in
# a subshell, so leaving it will continue the loop.
# Enter either bare repository or .git subdir
case $arg in
*.git)
cd -- "$arg" || exit
;;
*)
cd -- "$arg"/.git || exit
;;
esac
# Remove any original refs from a prior rewrite
if [ -e refs/original ] ; then
rm -r -- refs/original || exit
fi
# Check for bad references or other integrity/sanity problems
git fsck --full --no-reflogs || exit
# Expire dangling references
git reflog expire --all --expire=now --expire-unreachable=now || exit
# Remove dangling references
git gc --prune=now --aggressive || exit
) done
|