From 2ad691b0234a739fa74c7e97beda6f90ee3ff7d4 Mon Sep 17 00:00:00 2001 From: "Kyle J. McKay" Date: Mon, 8 Sep 2014 22:26:09 -0700 Subject: [PATCH] gc.sh: remove stale leftover pack crud If there are any files in objects/pack matching pack-.ext that are more than an hour old and do NOT have a matching pack-.pack file then remove them as they are crud. --- jobd/gc.sh | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/jobd/gc.sh b/jobd/gc.sh index 520a306..ba51569 100755 --- a/jobd/gc.sh +++ b/jobd/gc.sh @@ -163,6 +163,24 @@ fi progress "+ [$proj] garbage check (`date`)" +# Remove any stale pack remnants that are more than an hour old. +# Stale pack fragments are defined as any pack-.ext where .ext is NOT +# .pack AND the corresponding .pack DOES NOT exist. A bunch of stale +# pack-.idx files without their corresponding .pack files are worthless +# and just waste space. Normally there shouldn't be any remnants but actually +# this can happen when things are interrupted at just the wrong time. +# Note that the objects/pack directory is created by git init and should +# always exist. +octet='[0-9a-f][0-9a-f]' +octet4="$octet$octet$octet$octet" +octet20="$octet4$octet4$octet4$octet4$octet4" +find objects/pack -maxdepth 1 -type f -mmin +60 -name "pack-$octet20.?*" | \ +sed -e 's/^objects\/pack\/pack-//; s/\..*$//' | sort -u | \ +while read packsha; do + [ ! -e "objects/pack/pack-$packsha.pack" ] || continue + rm -f "objects/pack/pack-$packsha".?* +done + # safe pruning: we put all our objects in all forks, then we can # safely get rid of extra ones; repacks in forks will get rid of # the redundant ones again then @@ -196,6 +214,7 @@ if [ -d "../${forkdir##*/}" ]; then fi quiet=; [ -n "$show_progress" ] || quiet=-q + git pack-refs --all repack_gfi_packs git repack $packopts -a -d -l $quiet -- 2.11.4.GIT