gc: allow gc --auto to run pre-auto-gc outside Girocco
commitc76635a2777cc40b92fdbd7123ba6b0192dd7d46
authorKyle J. McKay <mackyle@gmail.com>
Mon, 1 Jan 2018 14:24:29 +0000 (1 06:24 -0800)
committerKyle J. McKay <mackyle@gmail.com>
Mon, 1 Jan 2018 14:24:29 +0000 (1 06:24 -0800)
tree7b5d62fbee9d049e86b1f0ef6c135c6d847b15f0
parentd5205b662cfb6043c670861776078684bbdb3ee5
gc: allow gc --auto to run pre-auto-gc outside Girocco

Until recently, Girocco did not have a pre-auto-gc hook.  Girocco
took great pains to make sure that auto gc never took place at all.

Now Girocco does have a pre-auto-gc hook (that always declines to
perform any auto gc).  In addition, when the $autogchack has been
turned on the pre-auto-gc hook may actually end up running if
non-Girocco activity modifies the repository.

Furthermore, since the pre-auto-gc hook is there and sometimes might
be run, Girocco helpfully takes that opportunity to set the
.needsgc flag on the repository if it appears to need gc run on it.

Improve on this situation by always allowing the pre-auto-gc hook
to run for external Girocco activity even when $autogchack is not
enabled (just not with the same frequency as for $autogchack) so
that the .needsgc flag can be activated in a more timely manner.

Additionally arrange for gc.auto=0 to be set while Girocco is running.

Except by deliberate tampering, this will always defeat automatic
gc while still allowing .needsgc to get set when needed.

The temporary "gc.auto=0" setting will only be effective with Git
v1.7.3 and later, but an alternate environment variable will still
be activated which will cause the pre-auto-gc hook to always deny
auto gc anyway in that case.

The abominable core.hooksPath did not appear until Git v2.9.0 which
could perhaps cause Git not to find its hooks somehow, but then the
"gc.auto=0" setting would have taken precedence before that anyhow.

Furthermore, if at least Git v2.6.3 is running, it will pick up the
new "preciousObjects=1" setting and decline to run auto gc anyway.

In other words, deliberate tampering with the intent of bypassing
the protections that prevent auto gc from running would be necessary
for "gc --auto" to ever actually be run in a situation where it
would actually spawn "git prune" and therefore be in a position to
end up pruning any objects.

When $autogchack is not active, the settings chosen for gc.auto and
gc.autopacklimit are just a tad bit higher than what would trigger
.needsgc to be set.  In other words, if $autogchack is not set and
external activity does exceed the threshold and the pre-auto-gc
hook gets run it will almost certainly end up setting the .needsgc
flag.  This way pre-auto-gc will only run when it's likely to
actually do something.

Signed-off-by: Kyle J. McKay <mackyle@gmail.com>
Girocco/Project.pm
bin/git-shell-verify
jobd/maintain-auto-gc-hack.sh
jobs/updateweb.sh
shlib.sh
toolbox/update-all-config.pl