From 53f31b92c61999ec6734dc67fa9c03d9196e8acb Mon Sep 17 00:00:00 2001 From: Petr Baudis Date: Fri, 30 Oct 2009 01:31:23 +0100 Subject: [PATCH] jobs/gccheck.sh: Split off one-repo worker to jobs/gc.sh --- jobs/gc.sh | 32 ++++++++++++++++++++++++++++ jobs/gccheck.sh | 65 ++++++++++++++++----------------------------------------- 2 files changed, 50 insertions(+), 47 deletions(-) create mode 100755 jobs/gc.sh rewrite jobs/gccheck.sh (75%) diff --git a/jobs/gc.sh b/jobs/gc.sh new file mode 100755 index 0000000..f277153 --- /dev/null +++ b/jobs/gc.sh @@ -0,0 +1,32 @@ +#!/bin/bash + +. @basedir@/shlib.sh + +dir="$1" + +progress "+ `date` $dir" + +# safe pruning: we put all our objects to all forks, then we can +# safely get rid of extra ones; repacks in forks will get rid of +# the redundant ones again then +forkdir="${dir%.git}" +if [ -d "$forkdir" ]; then + pushd "$cfg_reporoot/$dir" + get_repo_list "$forkdir/" | + while read fork; do + # Match objects in parent project + for d in objects/?? objects/pack; do + [ "$d" != "objects/??" ] || continue + mkdir -p "$cfg_reporoot/$forkdir/$fork/$d" + ln -f "$d"/* "$cfg_reporoot/$forkdir/$fork/$d" + done + done + popd +fi + +git --git-dir="$dir" repack -A -d --window-memory=3G -l -q +git --git-dir="$dir" prune +git --git-dir="$dir" update-server-info +date -R >"$dir/.last_gc" + +progress "- `date` $dir" diff --git a/jobs/gccheck.sh b/jobs/gccheck.sh dissimilarity index 75% index 7219edc..6665ae9 100755 --- a/jobs/gccheck.sh +++ b/jobs/gccheck.sh @@ -1,47 +1,18 @@ -#!/bin/bash - -. @basedir@/shlib.sh - -if [ -e /tmp/gitupdatelock ]; then - echo "Locked!" >&2 - exit 1 -fi -touch /tmp/gitupdatelock - -rootdir="$cfg_reporoot" - -repack() -{ - dir="$1" - progress "+ `date` $dir" - # safe pruning: we put all our objects to all forks, then we can - # safely get rid of extra ones; repacks in forks will get rid of - # the redundant ones again then - forkdir="${dir%.git}" - if [ -d "$forkdir" ]; then - pushd "$rootdir/$dir" - get_repo_list "$forkdir/" | - while read fork; do - # Match objects in parent project - for d in objects/?? objects/pack; do - [ "$d" != "objects/??" ] || continue - mkdir -p "$rootdir/$forkdir/$fork/$d" - ln -f "$d"/* "$rootdir/$forkdir/$fork/$d" - done - done - popd - fi - - git --git-dir="$dir" repack -A -d --window-memory=3G -l -q - git --git-dir="$dir" prune - git --git-dir="$dir" update-server-info - date -R >"$dir/.last_gc" - progress "- `date` $dir" -} - -get_repo_list | - while read dir; do - repack "$dir" - done 2>&1 | grep -v '^Pack.*created\.$' - -rm /tmp/gitupdatelock +#!/bin/bash + +. @basedir@/shlib.sh + +if [ -e /tmp/gitupdatelock ]; then + echo "Locked!" >&2 + exit 1 +fi +touch /tmp/gitupdatelock + +rootdir="$cfg_reporoot" + +get_repo_list | + while read dir; do + "$cfg_basedir"/jobs/gc.sh "$dir" + done 2>&1 | grep -v '^Pack.*created\.$' + +rm /tmp/gitupdatelock -- 2.11.4.GIT