From e70dab391da27166973e4ed8a8ea5052ca3dacf1 Mon Sep 17 00:00:00 2001
From: Oswald Buddenhagen <oswald.buddenhagen@digia.com>
Date: Mon, 20 Oct 2014 15:05:13 +0200
Subject: [PATCH] deal with overzealous garbage collection
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

every repo should have refs/changes (because fetching changes is the
first thing the bot does after cloning a repo), but with the default
config, gc will pack the refs, and the directory vanishes if no refs
were created for too long (which also breaks our cleanup).
don't error out when that happens.

also document how to avoid that situation to start with.

Change-Id: I92d539785a9810c02263f954d9299169d2fa3f2c
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
Reviewed-by: Simo Fält <simo.falt@digia.com>
---
 git-hooks/gerrit-bot-cleanup | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/git-hooks/gerrit-bot-cleanup b/git-hooks/gerrit-bot-cleanup
index 97cfde3..ca8da11 100755
--- a/git-hooks/gerrit-bot-cleanup
+++ b/git-hooks/gerrit-bot-cleanup
@@ -20,6 +20,8 @@ if test -z "$root"; then
 fi
 cd "$root" || exit
 find -name '*.git' -type d -prune | while read dir; do (
+    # use "git config --global gc.packrefs notbare" to make sure this works
+    test -d $dir/refs/changes || exit
     echo "Entering $dir ..."
     cd "$dir" || exit
     find refs/changes -mindepth 1 -mtime +10 -delete
-- 
GitLab