hooks: detect ref changes at gc --auto time
[girocco/readme.git] / hooks / pre-auto-gc
blob36f796fef87d7432a85284e25bc37921d2fa7903
1 #!/bin/sh
3 # Prevent any gc --auto from taking place
4 # And make $Girocco::Config::autogchack happen
6 # Beware, we MAY be running in a chroot!
8 # If GIROCCO_SUPPRESS_AUTO_GC_UPDATE immediately exit suppressing auto gc
9 [ "${GIROCCO_SUPPRESS_AUTO_GC_UPDATE:-0}" = "0" ] || exit 1
11 # If we're in the chroot immediately exit suppressing auto gc
12 [ -x @perlbin@ ] || exit 1
14 . @basedir@/shlib.sh
16 set -e
18 # If $Girocco::Config::autogchack is false we can exit early
19 # We can't test for .nofetch until all the rest so "mirror" does not help
20 [ "${cfg_autogchack:-0}" != "0" ] || exit 1
22 # Make sure the current directory is where we expect to be
23 [ "${GIT_DIR+set}" != "set" ] || cd "${GIT_DIR:-.}" || exit 1
24 case "${PWD%/*}" in */worktrees)
25 # Gah!
27 # But it COULD just be a coincidence...
28 [ -s commondir ] && [ -s HEAD ] &&
29 _cmndir= && read -r _cmndir <commondir 2>/dev/null &&
30 [ -n "$_cmndir" ] && [ -d "$_cmndir" ]
31 then
32 # ...it is not, fix it!
33 cd "$_cmndir" || exit 1
35 esac
36 [ "${GIT_DIR+set}" != "set" ] || GIT_DIR="."
38 # Get out of the mob
39 case "$PWD" in *?/mob)
40 cd ..
41 GIROCCO_PERSONAL_MOB=1
42 esac
44 umask 002
46 _shlib_done=1
47 unset GIROCCO_SUPPRESS_AUTO_GC_UPDATE
48 . "$cfg_basedir/jobd/generate-auto-gc-update.sh"
49 generate_auto_gc_update
51 exit 1