Skip to content

Commit 4461792

Browse files
flichtenheldgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent c2e357c commit 4461792

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

perl/Git.pm

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -632,15 +632,15 @@ The synopsis is like:
632632
"$name <$email>" eq ident_person($name);
633633
$time_tz =~ /^\d+ [+-]\d{4}$/;
634634
635-
Both methods must be called on a repository instance.
636-
637635
=cut
638636

639637
sub ident {
640-
my ($self, $type) = @_;
638+
my ($self, $type) = _maybe_self(@_);
641639
my $identstr;
642640
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);
644644
} else {
645645
$identstr = $type;
646646
}
@@ -652,8 +652,8 @@ sub ident {
652652
}
653653

654654
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]);
657657
return "$ident[0] <$ident[1]>";
658658
}
659659

0 commit comments

Comments
 (0)