@@ -338,9 +338,9 @@ static struct ref_cache *get_loose_ref_cache(struct files_ref_store *refs)
338338 return refs -> loose ;
339339}
340340
341- static int files_read_raw_ref (struct ref_store * ref_store , const char * refname ,
342- struct object_id * oid , struct strbuf * referent ,
343- unsigned int * type , int * failure_errno )
341+ static int read_ref_internal (struct ref_store * ref_store , const char * refname ,
342+ struct object_id * oid , struct strbuf * referent ,
343+ unsigned int * type , int * failure_errno , int skip_packed_refs )
344344{
345345 struct files_ref_store * refs =
346346 files_downcast (ref_store , REF_STORE_READ , "read_raw_ref" );
@@ -381,7 +381,7 @@ static int files_read_raw_ref(struct ref_store *ref_store, const char *refname,
381381 if (lstat (path , & st ) < 0 ) {
382382 int ignore_errno ;
383383 myerr = errno ;
384- if (myerr != ENOENT )
384+ if (myerr != ENOENT || skip_packed_refs )
385385 goto out ;
386386 if (refs_read_raw_ref (refs -> packed_ref_store , refname , oid ,
387387 referent , type , & ignore_errno )) {
@@ -425,7 +425,8 @@ static int files_read_raw_ref(struct ref_store *ref_store, const char *refname,
425425 * ref is supposed to be, there could still be a
426426 * packed ref:
427427 */
428- if (refs_read_raw_ref (refs -> packed_ref_store , refname , oid ,
428+ if (skip_packed_refs ||
429+ refs_read_raw_ref (refs -> packed_ref_store , refname , oid ,
429430 referent , type , & ignore_errno )) {
430431 myerr = EISDIR ;
431432 goto out ;
@@ -470,6 +471,27 @@ static int files_read_raw_ref(struct ref_store *ref_store, const char *refname,
470471 return ret ;
471472}
472473
474+ static int files_read_raw_ref (struct ref_store * ref_store , const char * refname ,
475+ struct object_id * oid , struct strbuf * referent ,
476+ unsigned int * type , int * failure_errno )
477+ {
478+ return read_ref_internal (ref_store , refname , oid , referent , type , failure_errno , 0 );
479+ }
480+
481+ static int files_read_symbolic_ref (struct ref_store * ref_store , const char * refname ,
482+ struct strbuf * referent )
483+ {
484+ struct object_id oid ;
485+ int failure_errno , ret ;
486+ unsigned int type ;
487+
488+ ret = read_ref_internal (ref_store , refname , & oid , referent , & type , & failure_errno , 1 );
489+ if (ret )
490+ return ret ;
491+
492+ return !(type & REF_ISSYMREF );
493+ }
494+
473495int parse_loose_ref_contents (const char * buf , struct object_id * oid ,
474496 struct strbuf * referent , unsigned int * type ,
475497 int * failure_errno )
@@ -3286,6 +3308,7 @@ struct ref_storage_be refs_be_files = {
32863308
32873309 files_ref_iterator_begin ,
32883310 files_read_raw_ref ,
3311+ files_read_symbolic_ref ,
32893312
32903313 files_reflog_iterator_begin ,
32913314 files_for_each_reflog_ent ,
0 commit comments