From: R. Steve McKown Date: Mon, 5 Apr 2010 14:32:54 +0000 (-0600) Subject: Add a server-gc script. Git seems to automatically gc, so this isn't needed. X-Git-Url: https://oss.titaniummirror.com/gitweb?p=git-utils.git;a=commitdiff_plain;h=d0750a70c888c1172a9cf1c0606b490434774e5d Add a server-gc script. Git seems to automatically gc, so this isn't needed. --- 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