6 trap 'if [ $? != 0 ]; then echo "gc failed dir: $PWD" >&2; fi; rm -f "$bang_log"' EXIT
9 [ "$cfg_permission_control" != "Hooks" ] ||
umask 000
12 cd "$cfg_reporoot/$proj.git"
14 # date -R is linux-only, POSIX equivalent is '+%a, %d %b %Y %T %z'
15 datefmt
='+%a, %d %b %Y %T %z'
17 if check_interval lastgc
$cfg_min_gc_interval; then
18 progress
"= [$proj] garbage check skip (last at $(config_get lastgc))"
22 progress
"x [$proj] garbage check disabled"
25 progress
"+ [$proj] garbage check (`date`)"
27 # safe pruning: we put all our objects in all forks, then we can
28 # safely get rid of extra ones; repacks in forks will get rid of
29 # the redundant ones again then
31 if [ -d "../${forkdir##*/}" ]; then
32 # It is enough to copy objects just one level down and get_repo_list
33 # takes a regular expression (which is automatically prefixed with '^')
34 # so we can easily match forks exactly one level down from this project
35 get_repo_list
"$forkdir/[^/]*:" |
37 # Ignore forks that do not exist or are symbolic links
38 [ ! -L "$cfg_reporoot/$fork.git" -a -d "$cfg_reporoot/$fork.git" ] || \
40 # Match objects in parent project
41 for d
in objects
/?? objects
/pack
; do
42 [ "$d" != "objects/??" ] ||
continue
43 mkdir
-p "$cfg_reporoot/$fork.git/$d"
44 [ "$d" != "objects/pack" ] || \
45 [ "$(echo objects/pack/*)" != \
46 "objects/pack/*" ] || \
48 ln -f "$d"/* "$cfg_reporoot/$fork.git/$d" ||
:
53 quiet
=; [ -n "$show_progress" ] || quiet
=-q
54 git repack
-a -d --window=50 --window-memory=1G
--depth=50 -l $quiet
56 git update-server-info
57 config_set lastgc
"$(date "$datefmt")"
59 progress
"- [$proj] garbage check (`date`)"