diff options
author | Junio C Hamano <gitster@pobox.com> | 2011-10-12 12:34:05 -0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2011-10-12 12:34:05 -0700 |
commit | 1ff5a41b6bfb250d2d055159caa9e00e008bc9d5 (patch) | |
tree | 1672e87d5472e340d94d4a5a4f5890ff4bc8c49d /perl/Git.pm | |
parent | afc71aa9e62b4bce35472143f063022b13aba3b1 (diff) | |
parent | cec5dae827f2255578807be6214ece1e0619b8e1 (diff) | |
download | git-1ff5a41b6bfb250d2d055159caa9e00e008bc9d5.tar.gz git-1ff5a41b6bfb250d2d055159caa9e00e008bc9d5.tar.xz |
Merge branch 'cs/perl-config-path-send-email'
* cs/perl-config-path-send-email:
use new Git::config_path() for aliasesfile
Add Git::config_path()
Diffstat (limited to 'perl/Git.pm')
-rw-r--r-- | perl/Git.pm | 32 |
1 files changed, 32 insertions, 0 deletions
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<VARIABLE>. The return value +is an expanded path or C<undef> 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<VARIABLE>. The return value |