]> oss.titaniummirror.com Git - git-utils.git/commitdiff
Add a server-gc script. Git seems to automatically gc, so this isn't needed.
authorR. Steve McKown <rsmckown@gmail.com>
Mon, 5 Apr 2010 14:32:54 +0000 (08:32 -0600)
committerR. Steve McKown <rsmckown@gmail.com>
Mon, 5 Apr 2010 14:32:54 +0000 (08:32 -0600)
server-gc [new file with mode: 0755]

diff --git a/server-gc b/server-gc
new file mode 100755 (executable)
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 <topdir>>" >&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