gc-git-svn.sh: set correct umask
[girocco.git] / jobd / gc-git-svn.sh
bloba4fba541e8b0c121d522d481e8eb879f24897313
1 #!/bin/sh
3 # Girocco installs a pre-auto-gc hook.
4 # When $GIROCCO_DIVERT_GIT_SVN_AUTO_GC is set to 1
5 # that hook, when executed, runs this script and
6 # no matter what exit code this script uses, the
7 # pre-auto-gc hook always exits with a code of 1
8 # immediately after this script finishes thereby
9 # aborting any Git-directed gc.
11 # The `git-svn fetch` operation periodically runs
12 # `git gc --auto` which ultimately causes this
13 # script to run provided the correct conditions
14 # are met and $GIROCCO_DIVERT_GIT_SVN_AUTO_GC is
15 # set to 1 in the environment.
17 # Both the jobd/update.sh and taskd/clone.sh scripts
18 # set and export GIROCCO_DIVERT_GIT_SVN_AUTO_GC=1
19 # and force `gc.auto=1` as well whenever they process
20 # a `git-svn` mirror.
22 . @basedir@/shlib.sh
23 . @basedir@/jobd/gc-util-functions.sh
25 set -e
27 [ -d objects ] || exit 1
29 umask 002
30 [ "$cfg_permission_control" != "Hooks" ] || umask 000
32 v_get_proj_from_dir proj
33 proj="${proj%.git}"
35 # packing options
36 packopts="--depth=50 --window=50 --window-memory=${var_window_memory:-1g}"
37 quiet="-q"; [ "${show_progress:-0}" = "0" ] || quiet=
39 # pack any existing, non-packed loose objects into a new _l.pack file then run prune-packed
40 # note that prune-packed is NOT run beforehand -- the caller must do that if needed
41 # loose objects need not be part of complete commits/trees as --weak-naming is used
42 pack_incremental_loose_objects() {
43 _lpacks="$(run_combine_packs </dev/null --names --loose --weak-naming --incremental --non-empty --all-progress-implied ${quiet:---progress} $packopts)"
44 if [ -n "$_lpacks" ]; then
45 # We need to identify these packs later so we don't combine_packs them
46 for _objpack in $_lpacks; do
47 rename_pack "objects/pack/pack-$_objpack" "objects/pack/pack-${_objpack}_l" || :
48 done
49 git prune-packed $quiet
53 if lotsa_loose_objects; then
54 echo "Packing loose objects ($(date))"
55 pack_incremental_loose_objects
56 echo "Packing and pruning complete ($(date))"
59 exit 0