hooks: detect ref changes at gc --auto time
commit4fdffc86f0315a6c8d2c209a6165cb4da649d5f9
authorKyle J. McKay <mackyle@gmail.com>
Tue, 26 Dec 2017 01:28:18 +0000 (25 17:28 -0800)
committerKyle J. McKay <mackyle@gmail.com>
Tue, 26 Dec 2017 01:28:18 +0000 (25 17:28 -0800)
treee265e5131d80347b98052f01cd2ce30c60386321
parent8d191ed42558ae6099e54deb220bc1d9377f9fc8
hooks: detect ref changes at gc --auto time

Although just barely tolerated, changes can be made to a repository
managed by Girocco by directly using Git commands external to Girocco.

Any such ref changes will not be picked up by Girocco's ref change
notification mechanism nor will they be preserved as "recently
reachable" via the reflogs mechanism.

However, Git often runs the "git gc --auto" command after various
operations.  There is a pre-auto-gc hook that runs when the "--auto"
check decides something needs to be done.

Shanghai that mechanism into a means to detect and process ref changes
that have been made to a Girocco repository outside of Girocco.

Introduce a $Girocco::Config::autogchack setting that when set to
a true value (or the special value "mirror") activates the necessary
machinery to make it all happen.

It's not for free, so it's opt-in only.  Additionally using the
special "mirror" value activates it only for mirror projects which
incurs less overhead than also using it for push projects.

It's not perfect as not all Git commands cause "git gc --auto"
to be run.  However "git fetch" (and "git remote update") do and
as a result setting autogchack to "mirror" will make it so ref
changes as a result of performing manual fetches outside of
the normal Girocco mirror update mechanism will still send out
Girocco ref notifications.

Signed-off-by: Kyle J. McKay <mackyle@gmail.com>
13 files changed:
Girocco/Config.pm
Girocco/Project.pm
bin/git-shell-verify
hooks/post-receive
hooks/pre-auto-gc
install.sh
jailsetup.sh
jobd/gc.sh
jobd/generate-auto-gc-update.sh [new file with mode: 0755]
jobd/maintain-auto-gc-hack.sh [new file with mode: 0755]
jobd/update.sh
shlib.sh
toolbox/projtool.pl