From e6bdf888eb06c6a527c4e0696a0ce979128f0f24 Mon Sep 17 00:00:00 2001 From: "Kyle J. McKay" Date: Mon, 29 Jun 2020 09:32:10 -0700 Subject: [PATCH] jobd/gc.sh: inhibit skipgc if simple "signature"s do not match If it looks like gc can be skipped (because there's nothing to do), check the simple signatures (packs and refs) and if either (or both) is missing or either (or both) does not match the previous value, do not allow gc to be skipped. Signed-off-by: Kyle J. McKay --- jobd/gc.sh | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/jobd/gc.sh b/jobd/gc.sh index de406f0..6357970 100755 --- a/jobd/gc.sh +++ b/jobd/gc.sh @@ -821,6 +821,30 @@ if lastreceivesecs="$(config_get_date_seconds lastreceive)" && fi fi +# Now check the simple signatures if $skipgc and decline to skip if they do not match + +if [ -n "$skipgc" ]; then + # check the packs signature first, no previous sig => must run gc + phash="$(config_get girocco.gcsig.packs)" || : + [ -n "$phash" ] || skipgc= + if [ -n "$skipgc" ]; then + # a previous packs sig is available, check for a match + _chksig="$(list_packs -C objects/pack --exclude-no-idx --quiet . | + LC_ALL=C sort | git hash-object -t blob --stdin)" || : + [ "$phash" = "$_chksig" ] || skipgc= + fi +fi +if [ -n "$skipgc" ]; then + # check the refs signature second, no previous sig => must run gc + rhash="$(config_get girocco.gcsig.refs)" || : + [ -n "$rhash" ] || skipgc= + if [ -n "$skipgc" ]; then + # a previous refs sig is available, check for a match + v_compute_refs_sighash _chksig + [ "$rhash" = "$_chksig" ] || skipgc= + fi +fi + # Prevent any other simultaneous gc operations lock_gc -- 2.11.4.GIT