@@ -666,16 +666,19 @@ void HandleCandidate(GitObjectId pointsAt, string tagName, bool isPeeled)
666666
667667 // Both tag files and packed-refs might either contain lightweight or annotated tags.
668668 // tag files
669- var tagDir = Path . Combine ( this . CommonDirectory , "refs" , "tags" ) ;
670- foreach ( var tagFile in Directory . EnumerateFiles ( tagDir , "*" , SearchOption . AllDirectories ) )
669+ string tagDir = Path . Combine ( this . CommonDirectory , "refs" , "tags" ) ;
670+ if ( Directory . Exists ( tagDir ) )
671671 {
672- var tagObjId = GitObjectId . ParseHex ( File . ReadAllBytes ( tagFile ) . AsSpan ( ) . Slice ( 0 , 40 ) ) ;
672+ foreach ( string tagFile in Directory . EnumerateFiles ( tagDir , "*" , SearchOption . AllDirectories ) )
673+ {
674+ var tagObjId = GitObjectId . ParseHex ( File . ReadAllBytes ( tagFile ) . AsSpan ( ) . Slice ( 0 , 40 ) ) ;
673675
674- // \ is not legal in git tag names
675- var tagName = tagFile . Substring ( tagDir . Length + 1 ) . Replace ( '\\ ' , '/' ) ;
676- var canonical = $ "refs/tags/{ tagName } ";
676+ // \ is not legal in git tag names
677+ var tagName = tagFile . Substring ( tagDir . Length + 1 ) . Replace ( '\\ ' , '/' ) ;
678+ var canonical = $ "refs/tags/{ tagName } ";
677679
678- HandleCandidate ( tagObjId , canonical , false ) ;
680+ HandleCandidate ( tagObjId , canonical , false ) ;
681+ }
679682 }
680683
681684 // packed-refs file
0 commit comments