File tree 1 file changed +20
-0
lines changed
1 file changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -164,6 +164,16 @@ sub ref_sha1 {
164
164
my @refs ;
165
165
my $dir = dir( $self -> gitdir, ' refs' );
166
166
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
+
167
177
foreach my $file ( File::Find::Rule-> new-> file-> in($dir ) ) {
168
178
my $ref = ' refs/' . file($file )-> relative($dir )-> as_foreign(' Unix' );
169
179
if ( $ref eq $wantref ) {
@@ -204,6 +214,16 @@ sub master {
204
214
return $self -> ref (' refs/heads/master' );
205
215
}
206
216
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
+
207
227
sub get_object {
208
228
my ( $self , $sha1 ) = @_ ;
209
229
return unless $sha1 ;
You can’t perform that action at this time.
0 commit comments