File tree Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -164,6 +164,16 @@ sub ref_sha1 {
164164 my @refs ;
165165 my $dir = dir( $self -> gitdir, ' refs' );
166166 return unless -d $dir ;
167+
168+ if ($wantref eq " HEAD" ) {
169+ my $file = file($self -> gitdir, ' HEAD' );
170+ my $sha1 = file($file )-> slurp
171+ || confess(" Error reading $file : $! " );
172+ chomp $sha1 ;
173+ return $self -> ref_sha1($1 ) if $sha1 =~ / ^ref: (.*)/ ;
174+ return $sha1 ;
175+ }
176+
167177 foreach my $file ( File::Find::Rule-> new-> file-> in($dir ) ) {
168178 my $ref = ' refs/' . file($file )-> relative($dir )-> as_foreign(' Unix' );
169179 if ( $ref eq $wantref ) {
@@ -204,6 +214,16 @@ sub master {
204214 return $self -> ref (' refs/heads/master' );
205215}
206216
217+ sub head_sha1 {
218+ my $self = shift ;
219+ return $self -> ref_sha1(' HEAD' );
220+ }
221+
222+ sub head {
223+ my $self = shift ;
224+ return $self -> ref (' HEAD' );
225+ }
226+
207227sub get_object {
208228 my ( $self , $sha1 ) = @_ ;
209229 return unless $sha1 ;
You can’t perform that action at this time.
0 commit comments