git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 1/2] Add config_boolean() method to the Git perl module

From
Theodore Ts'o <tytso@mit.edu>
Date
Feb 20, 2007, 20:13 UTC
Message-ID
<11720024233629-git-send-email-tytso@mit.edu>
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
Next: Theodore Ts'o
Message 1 of 3 in “Add config_boolean() method to the Git perl module”
  1. 1/2 Add config_boolean() method to the Git perl moduleTheodore Ts'o, Feb 20, 2007
  2. 2/2 Allow git-remote to update named groups of remotesTheodore Ts'o, Feb 20, 2007
  3. Eric WongFeb 20, 2007

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.