]> git.ipfire.org Git - thirdparty/git.git/blobdiff - perl/Git.pm
Merge branch 'en/ort-perf-batch-9'
[thirdparty/git.git] / perl / Git.pm
index 54c9ed0ddee52e4d5b59b59b74e0dbc738ae3ac9..73ebbf80cc6f42cff20acdb6f1d94bc03f28e71f 100644 (file)
@@ -9,7 +9,7 @@ package Git;
 
 use 5.008;
 use strict;
-use warnings;
+use warnings $ENV{GIT_PERL_FATAL_WARNINGS} ? qw(FATAL all) : ();
 
 use File::Temp ();
 use File::Spec ();
@@ -619,6 +619,19 @@ Return path to the git repository. Must be called on a repository instance.
 
 sub repo_path { $_[0]->{opts}->{Repository} }
 
+=item hooks_path ()
+
+Return path to the hooks directory. Must be called on a repository instance.
+
+=cut
+
+sub hooks_path {
+       my ($self) = @_;
+
+       my $dir = $self->command_oneline('rev-parse', '--git-path', 'hooks');
+       my $abs = abs_path($dir);
+       return $abs;
+}
 
 =item wc_path ()
 
@@ -723,6 +736,32 @@ sub config_int {
        return scalar _config_common({'kind' => '--int'}, @_);
 }
 
+=item config_regexp ( RE )
+
+Retrieve the list of configuration key names matching the regular
+expression C<RE>. The return value is a list of strings matching
+this regex.
+
+=cut
+
+sub config_regexp {
+       my ($self, $regex) = _maybe_self(@_);
+       try {
+               my @cmd = ('config', '--name-only', '--get-regexp', $regex);
+               unshift @cmd, $self if $self;
+               my @matches = command(@cmd);
+               return @matches;
+       } catch Git::Error::Command with {
+               my $E = shift;
+               if ($E->value() == 1) {
+                       my @matches = ();
+                       return @matches;
+               } else {
+                       throw $E;
+               }
+       };
+}
+
 # Common subroutine to implement bulk of what the config* family of methods
 # do. This currently wraps command('config') so it is not so fast.
 sub _config_common {