All it does is refuse all pushed changes. Execute it with empty stdin to simulate no changes:
$ .git/hooks/pre-receive </dev/null
Output
Use of uninitialized value $CFG in substitution (s///) at /usr/local/share/perl/5.20.2/Git/Hooks.pm line 80.
Use of uninitialized value $CFG in lc at /usr/local/share/perl/5.20.2/Git/Hooks.pm line 81.
Impact
This affects all kinds of hooks, whenever they return false to indicate failure.
Cause
This regressed in a971c01b7497515ca3e87e08a6f5e45a263082a9. At line 80, $CFG gets the value $hook->{package}, which is set at line 37:
*{"Git::Hooks::$installer"} = sub (&) {
push @{$Hooks{$hook}}, {
package => scalar(caller(1)), # <-- problem here
sub => shift(@_),
};
}
The problem is that scalar(caller(1)) is undef. The documentation for caller is not great. It actually goes back by one additional call frame.
Steps to reproduce
Place this script in
.git/hooks/pre-receive
:All it does is refuse all pushed changes. Execute it with empty stdin to simulate no changes:
Output
Impact
This affects all kinds of hooks, whenever they return false to indicate failure.
Cause
This regressed in a971c01b7497515ca3e87e08a6f5e45a263082a9. At line 80,
$CFG
gets the value$hook->{package}
, which is set at line 37:The problem is that
scalar(caller(1))
isundef
. The documentation forcaller
is not great. It actually goes back by one additional call frame.Solution
Just use
scalar(caller)