From 59c0d315317cd78ba2c9c9f419d7387e4054437b Mon Sep 17 00:00:00 2001 From: "Kyle J. McKay" Date: Sun, 24 Dec 2017 22:45:32 -0800 Subject: [PATCH] hooks: add pre-auto-gc hook Girocco takes great care to avoid ever having auto gc trigger. However, just before it does there's one final, last-ditch opportunity to stop it. A pre-auto-gc hook that always exits with a non-zero status. Since having a pre-auto-gc hook does not normally incur any penalties as it will not normally ever be run by Girocco, provide one as a form of cheap insurance against "git gc --auto" accidents. Signed-off-by: Kyle J. McKay --- Girocco/Project.pm | 2 +- hooks/pre-auto-gc | 6 ++++++ install.sh | 2 +- toolbox/update-all-hooks.sh | 2 +- 4 files changed, 9 insertions(+), 3 deletions(-) create mode 100755 hooks/pre-auto-gc diff --git a/Girocco/Project.pm b/Girocco/Project.pm index b3f90a7..42afeb2 100644 --- a/Girocco/Project.pm +++ b/Girocco/Project.pm @@ -555,7 +555,7 @@ sub _hook_install { sub _hooks_install { my $self = shift; - foreach my $hook ('pre-receive', 'post-receive', 'update') { + foreach my $hook ('pre-auto-gc', 'pre-receive', 'post-receive', 'update') { $self->_hook_install($hook); } } diff --git a/hooks/pre-auto-gc b/hooks/pre-auto-gc new file mode 100755 index 0000000..b062968 --- /dev/null +++ b/hooks/pre-auto-gc @@ -0,0 +1,6 @@ +#!/bin/sh +# +# Prevent any gc --auto from taking place +# + +exit 1 diff --git a/install.sh b/install.sh index 047e0ae..5a2863f 100755 --- a/install.sh +++ b/install.sh @@ -694,7 +694,7 @@ echo "*** Setting up global hook scripts..." # Otherwise an incoming push might slip in and fail to run the hook script! # The underlying rename(2) function call provides this and mv will use it. # First add hook scripts -hooks="pre-receive post-receive update" +hooks="pre-auto-gc pre-receive post-receive update" for hook in $hooks; do cat "$basedir/hooks/$hook" >"$cfg_reporoot/_global/hooks/$hook.$$" chown "$cfg_mirror_user""$owngroup" "$cfg_reporoot/_global/hooks/$hook.$$" || diff --git a/toolbox/update-all-hooks.sh b/toolbox/update-all-hooks.sh index 942b026..1c58a6b 100755 --- a/toolbox/update-all-hooks.sh +++ b/toolbox/update-all-hooks.sh @@ -35,7 +35,7 @@ eval "$cmd" | [ -d "$projdir" ] || { echo "$proj: does not exist -- skipping"; continue; } ! [ -e "$projdir/.nohooks" ] || { echo "$proj: .nohooks found -- skipping"; continue; } updates= - for hook in pre-receive post-receive update; do + for hook in pre-auto-gc pre-receive post-receive update; do doln= if [ -f "$projdir/hooks/$hook" ]; then if -- 2.11.4.GIT