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: