summaryrefslogtreecommitdiff
path: root/perl
diff options
context:
space:
mode:
authorTheodore Ts'o <tytso@mit.edu>2007-02-20 15:13:42 -0500
committerJunio C Hamano <junkio@cox.net>2007-02-20 23:58:37 -0800
commit7b9a13ece8a1e7c0fd2a82d4bd4fcf0a9ce0e8c4 (patch)
treeea5508c26893be7d6820a64f6bcafdbba5cce09e /perl
parent4a6b9bb60ab3cdb3a749ec43763845a7a60d40d4 (diff)
downloadgit-7b9a13ece8a1e7c0fd2a82d4bd4fcf0a9ce0e8c4.tar.gz
Add config_boolean() method to the Git perl module
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu> Signed-off-by: Junio C Hamano <junkio@cox.net>
Diffstat (limited to 'perl')
-rw-r--r--perl/Git.pm30
1 files changed, 30 insertions, 0 deletions
diff --git a/perl/Git.pm b/perl/Git.pm
index f2c156cde9..b5b1cf5edc 100644
--- a/perl/Git.pm
+++ b/perl/Git.pm
@@ -516,6 +516,36 @@ sub config {
}
+=item config_boolean ( VARIABLE )
+
+Retrieve the boolean configuration C<VARIABLE>.
+
+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 )