@matheusbsbs / matheus-bagliano / commits / 44617928ae
Fork 0

Git.pm: Don't require repository instance for ident

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> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Frank Lichtenheld committed Mar 14, 2008 at 18:29 UTC 44617928ae4731b6139d87b978ddbc4860154222
1 file changed +6 -6
perl/Git.pm
+6 -6
@@ -632,15 +632,15 @@ The synopsis is like:
632 "$name <$email>" eq ident_person($name);
633 $time_tz =~ /^\d+ [+-]\d{4}$/;
634
635 -Both methods must be called on a repository instance.
636 -
635 =cut
636
637 sub ident {
640 - my ($self, $type) = @_;
638 + my ($self, $type) = _maybe_self(@_);
639 my $identstr;
640 if (lc $type eq lc 'committer' or lc $type eq lc 'author') {
643 - $identstr = $self->command_oneline('var', 'GIT_'.uc($type).'_IDENT');
641 + my @cmd = ('var', 'GIT_'.uc($type).'_IDENT');
642 + unshift @cmd, $self if $self;
643 + $identstr = command_oneline(@cmd);
644 } else {
645 $identstr = $type;
646 }
@@ -652,8 +652,8 @@ sub ident {
652 }
653
654 sub ident_person {
655 - my ($self, @ident) = @_;
656 - $#ident == 0 and @ident = $self->ident($ident[0]);
655 + my ($self, @ident) = _maybe_self(@_);
656 + $#ident == 0 and @ident = $self ? $self->ident($ident[0]) : ident($ident[0]);
657 return "$ident[0] <$ident[1]>";
658 }
659