From 7d30ff584742fd5df4d9dcdd67ca76809194b50f Mon Sep 17 00:00:00 2001 From: "Kyle J. McKay" Date: Fri, 9 Feb 2018 09:42:52 -0800 Subject: [PATCH] notify: ignore single-level ref name changes by default When using linked working trees with a Girocco repository (or even, gasp, a non-bare repository), "single-level" refs may end up being created in the repository such as "refs/stash". These "single-level" refs are almost always meant to be local and although a mirror clone will indeed fetch such refs, it's notable that even a "mirror" push will not push them. Changes to such refs are not generally something that should generate any kind of notification. Therefore ignore changes to any such "single-level" refs when presented to the Girocco notification machinery unless the new $Girocco::Config::notify_single_level preference has been explicitly set to a true value. Signed-off-by: Kyle J. McKay --- Girocco/Config.pm | 10 ++++++++++ taskd/taskd.pl | 2 ++ 2 files changed, 12 insertions(+) diff --git a/Girocco/Config.pm b/Girocco/Config.pm index 0a88166..5c5f701 100644 --- a/Girocco/Config.pm +++ b/Girocco/Config.pm @@ -914,6 +914,15 @@ our $autogchack = 0; # the case. our $localhooks = 0; +# If this is set to a true value changes to single-level refs (e.g. refs/stash) +# will be passed through to the notification machinery. +# Usually this is NOT wanted, especially when linked working trees are being +# used with the repository. +# However, in the unlikely event that changes to such ref names should NOT be +# ignored, this value may be set to any true value. +# RECOMMENDED VALUE: 0 +our $notify_single_level = 0; + # If this is set to a non-empty value it will become the default value for # all repositories' girocco.notifyHook value. # Whenever taskd.pl receives a batch of ref changes for processing, it first @@ -1001,6 +1010,7 @@ $jailreporoot =~ s,^/+,,; ($reporoot) or die "Girocco::Config \$reporoot must be set"; ($jailreporoot) or die "Girocco::Config \$jailreporoot must be set"; $disable_jailsetup = $disable_jailsetup ? 1 : ''; +$notify_single_level = $notify_single_level ? 1 : ''; (not $mob or $mob eq 'mob') or die "Girocco::Config \$mob must be undef (or '') or 'mob'"; (not $min_key_length or $min_key_length =~ /^[1-9][0-9]*$/) or die "Girocco::Config \$min_key_length must be undef or numeric"; diff --git a/taskd/taskd.pl b/taskd/taskd.pl index dbe2f44..1d11b96 100755 --- a/taskd/taskd.pl +++ b/taskd/taskd.pl @@ -710,6 +710,7 @@ sub ref_change { $username && $name && $oldrev && $newrev && $ref or return 0; $oldrev =~ /^[0-9a-f]{40}$/ && $newrev =~ /^[0-9a-f]{40}$/ && $ref =~ m{^refs/} or return 0; $newrev ne $oldrev or return 0; + $Girocco::Config::notify_single_level || $ref =~ m(^refs/[^/]+/[^/]) or return 0; Girocco::Project::does_exist($name, 1) or die "no such project: $name"; my $proj = Girocco::Project->load($name); @@ -761,6 +762,7 @@ sub ref_changes { my ($oldrev, $newrev, $ref) = split(/\s+/, $change); $oldrev ne "done" or last; $oldrev =~ /^[0-9a-f]{40}$/ && $newrev =~ /^[0-9a-f]{40}$/ && $ref =~ m{^refs/} or next; + $Girocco::Config::notify_single_level || $ref =~ m(^refs/[^/]+/[^/]) or next; if ($ref =~ m{^refs/heads/.}) { if ($oldrev =~ /^0{40}$/) { delete $oldheads{$ref}; -- 2.11.4.GIT