@@ -175,7 +175,6 @@ sub refs {
175
175
176
176
sub ref_sha1 {
177
177
my ( $self , $wantref ) = @_ ;
178
- my @refs ;
179
178
my $dir = dir( $self -> gitdir, ' refs' );
180
179
return unless -d $dir ;
181
180
@@ -184,8 +183,7 @@ sub ref_sha1 {
184
183
my $sha1 = file($file )-> slurp
185
184
|| confess(" Error reading $file : $! " );
186
185
chomp $sha1 ;
187
- return $self -> ref_sha1($1 ) if $sha1 =~ / ^ref: (.*)/ ;
188
- return $sha1 ;
186
+ return _ensure_sha1_is_sha1( $self , $sha1 );
189
187
}
190
188
191
189
foreach my $file ( File::Find::Rule-> new-> file-> in($dir ) ) {
@@ -194,8 +192,7 @@ sub ref_sha1 {
194
192
my $sha1 = file($file )-> slurp
195
193
|| confess(" Error reading $file : $! " );
196
194
chomp $sha1 ;
197
- return $self -> ref_sha1($1 ) if $sha1 =~ / ^ref: (.*)/ ;
198
- return $sha1 ;
195
+ return _ensure_sha1_is_sha1( $self , $sha1 );
199
196
}
200
197
}
201
198
@@ -204,15 +201,18 @@ sub ref_sha1 {
204
201
foreach my $line ( $packed_refs -> slurp( chomp => 1 ) ) {
205
202
next if $line =~ / ^#/ ;
206
203
my ( $sha1 , my $name ) = split ' ' , $line ;
207
- if ( $name eq $wantref ) {
208
- return $self -> ref_sha1($1 ) if $sha1 =~ / ^ref: (.*)/ ;
209
- return $sha1 ;
210
- }
204
+ return _ensure_sha1_is_sha1( $self , $sha1 ) if $name eq $wantref ;
211
205
}
212
206
}
213
207
return undef ;
214
208
}
215
209
210
+ sub _ensure_sha1_is_sha1 {
211
+ my ( $self , $sha1 ) = @_ ;
212
+ return $self -> ref_sha1($1 ) if $sha1 =~ / ^ref: (.*)/ ;
213
+ return $sha1 ;
214
+ }
215
+
216
216
sub ref {
217
217
my ( $self , $wantref ) = @_ ;
218
218
return $self -> get_object( $self -> ref_sha1($wantref ) );
@@ -557,4 +557,3 @@ This module is free software; you can redistribute it or
557
557
modify it under the same terms as Perl itself.
558
558
559
559
=cut
560
-
0 commit comments