Merge branch 'master' into rorcz
[girocco/readme.git] / hooks / pre-auto-gc
blobe224a6fdc22598c1efd39725401c4040d0e187dc
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 # Make sure the current directory is where we expect to be
19 [ "${GIT_DIR+set}" != "set" ] || { [ -n "$GIT_DIR" ] && [ -d "$GIT_DIR" ]; } || unset GIT_DIR
20 [ -n "$GIT_DIR" ] || GIT_DIR="$(git rev-parse --git-dir)"
21 [ -n "$GIT_DIR" ] && cd -P "${GIT_DIR:-.}" || exit 1
22 case "${PWD%/*}" in */worktrees)
23 # Gah!
25 # But it COULD just be a coincidence...
26 [ -s commondir ] && [ -s HEAD ] &&
27 _cmndir= && read -r _cmndir <commondir 2>/dev/null &&
28 [ -n "$_cmndir" ] && [ -d "$_cmndir" ]
29 then
30 # ...it is not, fix it!
31 cd -P "$_cmndir" || exit 1
33 esac
34 GIT_DIR="." GIT_PREFIX= && export GIT_DIR
36 # Get out of the mob
37 case "$PWD" in *?/mob)
38 cd ..
39 GIROCCO_PERSONAL_MOB=1
40 esac
42 umask 002
44 # just in case
45 check_and_set_needsgc
47 _shlib_done=1
48 unset GIROCCO_SUPPRESS_AUTO_GC_UPDATE
49 . "$cfg_basedir/jobd/generate-auto-gc-update.sh"
50 generate_auto_gc_update
52 exit 1