@matheusbsbs / matheus-bagliano / commits / 7b9a13ece8
Fork 0

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>

Theodore Ts'o committed Feb 20, 2007 at 15:13 UTC 7b9a13ece8a1e7c0fd2a82d4bd4fcf0a9ce0e8c4
1 file changed +30
perl/Git.pm
+30
@@ -516,6 +516,36 @@ sub config {
516 }
517
518
519 +=item config_boolean ( VARIABLE )
520 +
521 +Retrieve the boolean configuration C<VARIABLE>.
522 +
523 +Must be called on a repository instance.
524 +
525 +This currently wraps command('config') so it is not so fast.
526 +
527 +=cut
528 +
529 +sub config_boolean {
530 + my ($self, $var) = @_;
531 + $self->repo_path()
532 + or throw Error::Simple("not a repository");
533 +
534 + try {
535 + return $self->command_oneline('config', '--bool', '--get',
536 + $var);
537 + } catch Git::Error::Command with {
538 + my $E = shift;
539 + if ($E->value() == 1) {
540 + # Key not found.
541 + return undef;
542 + } else {
543 + throw $E;
544 + }
545 + };
546 +}
547 +
548 +
549 =item ident ( TYPE | IDENTSTR )
550
551 =item ident_person ( TYPE | IDENTSTR | IDENTARRAY )