install.sh: expand @cfg_name@ in processed scripts
[girocco.git] / hooks / pre-auto-gc
blob98769bf0d4e8b45ade5cf23596517207571d7f61
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 GIROCCO_DIVERT_GIT_SVN_AUTO_GC divert to $basedir/jobd/gc-git-svn.sh
12 [ "${GIROCCO_DIVERT_GIT_SVN_AUTO_GC:-0}" = "0" ] || {
13 @basedir@/jobd/gc-git-svn.sh
14 exit 1
17 # If we're in the chroot immediately exit suppressing auto gc
18 [ -x @perlbin@ ] || exit 1
20 . @basedir@/shlib.sh
22 set -e
24 # Make sure the current directory is where we expect to be
25 [ "${GIT_DIR+set}" != "set" ] || { [ -n "$GIT_DIR" ] && [ -d "$GIT_DIR" ]; } || unset GIT_DIR
26 [ -n "$GIT_DIR" ] || GIT_DIR="$(git rev-parse --git-dir)"
27 [ -n "$GIT_DIR" ] && cd -P "${GIT_DIR:-.}" || exit 1
28 case "${PWD%/*}" in */worktrees)
29 # Gah!
31 # But it COULD just be a coincidence...
32 [ -s commondir ] && [ -s HEAD ] &&
33 _cmndir= && read -r _cmndir <commondir 2>/dev/null &&
34 [ -n "$_cmndir" ] && [ -d "$_cmndir" ]
35 then
36 # ...it is not, fix it!
37 cd -P "$_cmndir" || exit 1
39 esac
40 GIT_DIR="." GIT_PREFIX= && export GIT_DIR
42 # Get out of the mob
43 case "$PWD" in *?/mob)
44 cd ..
45 GIROCCO_PERSONAL_MOB=1
46 esac
48 umask 002
50 # just in case
51 check_and_set_needsgc
53 _shlib_done=1
54 unset GIROCCO_SUPPRESS_AUTO_GC_UPDATE
55 . "$cfg_basedir/jobd/generate-auto-gc-update.sh"
56 generate_auto_gc_update
58 exit 1