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

[PATCH 3/4] Git.pm: Don't require repository instance for ident

From
Frank Lichtenheld <frank@lichtenheld.de>
Date
Mar 14, 2008, 17:29 UTC
Message-ID
<1205515770-3424-4-git-send-email-frank@lichtenheld.de>
In-Reply-To
<1205515770-3424-3-git-send-email-frank@lichtenheld.de>

git var doesn't require to be called in a repository anymore, so don't require it either.

Signed-off-by: Frank Lichtenheld <frank@lichtenheld.de>
---
 perl/Git.pm |   12 ++++++------
 1 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/perl/Git.pm b/perl/Git.pm
index 67b3749..2e7f896 100644
--- a/perl/Git.pm
+++ b/perl/Git.pm
@@ -632,15 +632,15 @@ The synopsis is like:
 	"$name <$email>" eq ident_person($name);
 	$time_tz =~ /^\d+ [+-]\d{4}$/;
 
-Both methods must be called on a repository instance.
-
 =cut
 
 sub ident {
-	my ($self, $type) = @_;
+	my ($self, $type) = _maybe_self(@_);
 	my $identstr;
 	if (lc $type eq lc 'committer' or lc $type eq lc 'author') {
-		$identstr = $self->command_oneline('var', 'GIT_'.uc($type).'_IDENT');
+		my @cmd = ('var', 'GIT_'.uc($type).'_IDENT');
+		unshift @cmd, $self if $self;
+		$identstr = command_oneline(@cmd);
 	} else {
 		$identstr = $type;
 	}
@@ -652,8 +652,8 @@ sub ident {
 }
 
 sub ident_person {
-	my ($self, @ident) = @_;
-	$#ident == 0 and @ident = $self->ident($ident[0]);
+	my ($self, @ident) = _maybe_self(@_);
+	$#ident == 0 and @ident = $self ? $self->ident($ident[0]) : ident($ident[0]);
 	return "$ident[0] <$ident[1]>";
 }
 
-- 
1.5.4.4
Previous: Frank LichtenheldNext: Frank Lichtenheld
Message 4 of 6 in “Don't require to be in the repository if we don't need to”
  1. 0/4 Don't require to be in the repository if we don't need toFrank Lichtenheld, Mar 14, 2008
  2. 1/4 var: Don't require to be in a git repository.Frank Lichtenheld, Mar 14, 2008
  3. 2/4 Git.pm: Don't require a repository instance for configFrank Lichtenheld, Mar 14, 2008
  4. 3/4 Git.pm: Don't require repository instance for identFrank Lichtenheld, Mar 14, 2008
  5. 4/4 send-email: Don't require to be called in a repositoryFrank Lichtenheld, Mar 14, 2008
  6. Junio C HamanoMar 16, 2008

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.