X-Git-Url: https://oss.titaniummirror.com/gitweb?p=git-utils.git;a=blobdiff_plain;f=server-gc;fp=server-gc;h=b24ef89f791269a0cd96a11b6064879ecdbcbd3a;hp=0000000000000000000000000000000000000000;hb=d0750a70c888c1172a9cf1c0606b490434774e5d;hpb=bb0479526e419e1f61207daf6bea59132cec8459 diff --git a/server-gc b/server-gc new file mode 100755 index 0000000..b24ef89 --- /dev/null +++ b/server-gc @@ -0,0 +1,55 @@ +#!/bin/sh +# +# server-gc -- Run git-gc on each git repository found within the provided +# filesystem directory tree. Useful for shared on-server repos that don't +# automatically do gc operations. This script was first posted at +# http://groups.google.com/group/repo-discuss/web/repository-repacking +# +# NOTE: THIS UTILITY DOES NOT REALLY APPEAR TO BE NEEDED. + +if [ $(whoami) != "root" ]; then + echo "usage: $0 must be ran as root" >&2 + exit 1 +fi + +TOP=$1 +if [ ! -d "$TOP" ]; then + echo "usage: $0 >" >&2 + exit 1 +fi + +cd $TOP +for p in $(find . -type d -name \*.git | sed 's,^./,,') +do + d=$TOP/$p + echo + echo "*** Repository $d ***" + + git --git-dir=$d config repack.usedeltabaseoffset true + git --git-dir=$d config pack.compression 9 + git --git-dir=$d config pack.indexversion 2 + + git --git-dir=$d config gc.autopacklimit 4 + git --git-dir=$d config gc.packrefs true + git --git-dir=$d config gc.reflogexpire never + git --git-dir=$d config gc.reflogexpireunreachable never + + case $p in + kernel/lk.git) + : use defaults + ;; + kernel/*) + git --git-dir=$d config pack.threads 6 + git --git-dir=$d config pack.window 250 + git --git-dir=$d config pack.depth 50 + ;; + esac + + rm -rf $d/logs/refs/changes 2>/dev/null + + git --git-dir=$d gc --auto --aggressive --prune || break + + (find $d/refs/changes -type d | xargs rmdir; + find $d/refs/changes -type d | xargs rmdir + ) 2>/dev/null +done