Do not leave $bang_log behind in gc.sh or update.sh
[girocco.git] / jobd / gc.sh
blob30fc6250aa30c521995a71ced153754640780900
1 #!/bin/bash
3 . @basedir@/shlib.sh
5 set -e
6 trap 'if [ $? != 0 ]; then echo "gc failed dir: $PWD" >&2; fi; rm -f "$bang_log"' EXIT
8 proj="$1"
9 cd "$cfg_reporoot/$proj.git"
11 # date -R is linux-only, POSIX equivalent is '+%a, %d %b %Y %T %z'
12 datefmt='+%a, %d %b %Y %T %z'
14 if check_interval lastgc $cfg_min_gc_interval; then
15 progress "= [$proj] garbage check skip (last at $(config_get lastgc))"
16 exit 0
18 if [ -e .nogc ]; then
19 progress "x [$proj] garbage check disabled"
20 exit 0
22 progress "+ [$proj] garbage check (`date`)"
24 # safe pruning: we put all our objects in all forks, then we can
25 # safely get rid of extra ones; repacks in forks will get rid of
26 # the redundant ones again then
27 forkdir="$1"
28 if [ -d "../${forkdir##*/}" ]; then
29 get_repo_list "$forkdir/" |
30 while read fork; do
31 # Match objects in parent project
32 for d in objects/?? objects/pack; do
33 [ "$d" != "objects/??" ] || continue
34 mkdir -p "$cfg_reporoot/$fork.git/$d"
35 ln -f "$d"/* "$cfg_reporoot/$fork.git/$d" ||:
36 done
38 # fixup project permissions
39 >"$cfg_fixup_queue" echo "$fork"
40 done
43 quiet=; [ -n "$show_progress" ] || quiet=-q
44 git repack -a -d --window-memory=1G -l $quiet
45 git prune
46 git update-server-info
47 config_set lastgc "$(date "$datefmt")"
49 progress "- [$proj] garbage check (`date`)"