From: Theodore Ts'o Date: Tue, 20 Feb 2007 20:13:42 +0000 (-0500) Subject: Add config_boolean() method to the Git perl module X-Git-Tag: v1.5.1-rc1~264 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=7b9a13ece8a1e7c0fd2a82d4bd4fcf0a9ce0e8c4;p=git.git Add config_boolean() method to the Git perl module Signed-off-by: "Theodore Ts'o" Signed-off-by: Junio C Hamano --- diff --git a/perl/Git.pm b/perl/Git.pm index f2c156cde..b5b1cf5ed 100644 --- a/perl/Git.pm +++ b/perl/Git.pm @@ -516,6 +516,36 @@ sub config { } +=item config_boolean ( VARIABLE ) + +Retrieve the boolean configuration C. + +Must be called on a repository instance. + +This currently wraps command('config') so it is not so fast. + +=cut + +sub config_boolean { + my ($self, $var) = @_; + $self->repo_path() + or throw Error::Simple("not a repository"); + + try { + return $self->command_oneline('config', '--bool', '--get', + $var); + } catch Git::Error::Command with { + my $E = shift; + if ($E->value() == 1) { + # Key not found. + return undef; + } else { + throw $E; + } + }; +} + + =item ident ( TYPE | IDENTSTR ) =item ident_person ( TYPE | IDENTSTR | IDENTARRAY )