Add very brief mention of license in README
[girocco.git] / jobd / gc.sh
blob7eb0d4328873d8f3a4de03c179d46655f968ac0f
1 #!/bin/bash
3 . @basedir@/shlib.sh
5 set -e
7 proj="$1"
8 cd "$cfg_reporoot/$proj.git"
10 # date -R is linux-only, POSIX equivalent is '+%a, %d %b %Y %T %z'
11 datefmt='+%a, %d %b %Y %T %z'
13 if check_interval lastgc $cfg_min_gc_interval; then
14 progress "= [$proj] garbage check skip (last at $(config_get lastgc))"
15 exit 0
17 if [ -e .nogc ]; then
18 progress "x [$proj] garbage check disabled"
19 exit 0
21 progress "+ [$proj] garbage check (`date`)"
23 # safe pruning: we put all our objects to all forks, then we can
24 # safely get rid of extra ones; repacks in forks will get rid of
25 # the redundant ones again then
26 forkdir="$1"
27 if [ -d "../$forkdir" ]; then
28 get_repo_list "$forkdir/" |
29 while read fork; do
30 # Match objects in parent project
31 for d in objects/?? objects/pack; do
32 [ "$d" != "objects/??" ] || continue
33 mkdir -p "$cfg_reporoot/$fork.git/$d"
34 ln -f "$d"/* "$cfg_reporoot/$fork.git/$d" ||:
35 done
37 # fixup project permissions
38 >"$cfg_fixup_queue" echo "$fork"
39 done
42 quiet=; [ -n "$show_progress" ] || quiet=-q
43 git repack -a -d --window-memory=1G -l $quiet
44 git prune
45 git update-server-info
46 config_set lastgc "$(date "$datefmt")"
48 progress "- [$proj] garbage check (`date`)"