summaryrefslogtreecommitdiff
path: root/perl/Git.pm
diff options
context:
space:
mode:
authorCord Seele <cowose@googlemail.com>2011-09-30 10:52:24 (GMT)
committerJunio C Hamano <gitster@pobox.com>2011-09-30 19:34:38 (GMT)
commit9fef9e279055423363e110b7246a9b8bbcf0bd72 (patch)
tree2f8610b117bcbdfeadd8feb6cdd55e0bdf7d423b /perl/Git.pm
parent85e9c7e1d42849c5c3084a9da748608468310c0e (diff)
downloadgit-9fef9e279055423363e110b7246a9b8bbcf0bd72.zip
git-9fef9e279055423363e110b7246a9b8bbcf0bd72.tar.gz
git-9fef9e279055423363e110b7246a9b8bbcf0bd72.tar.bz2
Add Git::config_path()
Use --path option when calling 'git config' thus allow for pathname expansion, e.g. a tilde. Signed-off-by: Cord Seele <cowose@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'perl/Git.pm')
-rw-r--r--perl/Git.pm32
1 files changed, 32 insertions, 0 deletions
diff --git a/perl/Git.pm b/perl/Git.pm
index a86ab70..c279bfb 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