X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=perl%2FGit.pm;h=c279bfb2446880bb18a5e6c898ef533805e78e56;hb=e75a59adfcc4fd048690e5b25f9a8c31d8011d53;hp=a86ab709c25b5e110aa2708941cea560f82c1fa8;hpb=f52237576ab9ab054e8330ce5dc47f2020cbce74;p=git.git diff --git a/perl/Git.pm b/perl/Git.pm index a86ab709c..c279bfb24 100644 --- a/perl/Git.pm +++ b/perl/Git.pm @@ -627,6 +627,38 @@ sub config_bool { }; } + +=item config_path ( VARIABLE ) + +Retrieve the path configuration C. The return value +is an expanded path or C if it's not defined. + +This currently wraps command('config') so it is not so fast. + +=cut + +sub config_path { + my ($self, $var) = _maybe_self(@_); + + try { + my @cmd = ('config', '--path'); + unshift @cmd, $self if $self; + if (wantarray) { + return command(@cmd, '--get-all', $var); + } else { + return command_oneline(@cmd, '--get', $var); + } + } catch Git::Error::Command with { + my $E = shift; + if ($E->value() == 1) { + # Key not found. + return undef; + } else { + throw $E; + } + }; +} + =item config_int ( VARIABLE ) Retrieve the integer configuration C. The return value