From 77d569e3d9d4be730c358929d46372bc58549883 Mon Sep 17 00:00:00 2001 From: "Kyle J. McKay" Date: Wed, 7 Feb 2018 20:05:03 -0800 Subject: [PATCH] update.gc: check_and_set_needsgc before fetch Since check_and_set_needsgc is all nice and neatly bundled up in a function now, call it just before starting a mirror fetch in addition to the call after a successful fetch. This helps avoid excess pack buildup when the fetch itself succeeds in fetching a pack but Git refuses to complete the update for some reason (perhaps because a malicious Git-impersonation has attempted to update a ref/heads/... ref to point at a non-commit object) thus causing a "bang" exit. Without this extra check, the excess pack cleanup would not take place until the next regularly scheduled gc run which could potentially be many days away. Signed-off-by: Kyle J. McKay --- jobd/update.sh | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/jobd/update.sh b/jobd/update.sh index cd3f59f..7845c77 100755 --- a/jobd/update.sh +++ b/jobd/update.sh @@ -108,6 +108,14 @@ clean_git_env proj="${1%.git}" cd "$cfg_reporoot/$proj.git" +# Activate a mini-gc if needed +# We do this here as well as after a successful fetch so that if we're stuck +# in a fetch loop where fetches are succeeding in fetching new packs but the +# ref update is failing for some reason (perhaps a non-commit under refs/heads) +# and a previous invokation therefore had a "bang" exit then we will still +# get the .needsgc flag set in a timely fashion to avoid excess pack build up. +check_and_set_needsgc + trap 'if [ $? != 0 ]; then echo "update failed dir: $PWD" >&2; fi; rm -f "$bang_log"' EXIT trap 'exit 130' INT trap 'exit 143' TERM -- 2.11.4.GIT