git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Theodore Ts'o <tytso@mit.edu>
To: git@vger.kernel.org
Cc: Theodore Ts'o <tytso@mit.edu>
Subject: [PATCH 1/2] Add config_boolean() method to the Git perl module
Date: Tue, 20 Feb 2007 15:13:42 -0500	[thread overview]
Message-ID: <11720024233629-git-send-email-tytso@mit.edu> (raw)

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
---
 perl/Git.pm |   30 ++++++++++++++++++++++++++++++
 1 files changed, 30 insertions(+), 0 deletions(-)

diff --git a/perl/Git.pm b/perl/Git.pm
index f2c156c..51bd73e 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 )
-- 
1.5.0.1.38.g392d-dirty

             reply	other threads:[~2007-02-20 20:13 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-02-20 20:13 Theodore Ts'o [this message]
2007-02-20 20:13 ` [PATCH 2/2] Allow git-remote to update named groups of remotes Theodore Ts'o
2007-02-20 21:16 ` [PATCH 1/2] Add config_boolean() method to the Git perl module Eric Wong

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=11720024233629-git-send-email-tytso@mit.edu \
    --to=tytso@mit.edu \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).