@@ -12,6 +12,9 @@ internal sealed partial class GitRepository
1212 private readonly ConcurrentDictionary < string , Branch > cachedBranches = new ( ) ;
1313 private readonly ConcurrentDictionary < string , Commit > cachedCommits = new ( ) ;
1414 private readonly ConcurrentDictionary < string , Tag > cachedTags = new ( ) ;
15+ private readonly ConcurrentDictionary < string , Remote > cachedRemotes = new ( ) ;
16+ private readonly ConcurrentDictionary < string , Reference > cachedReferences = new ( ) ;
17+ private readonly ConcurrentDictionary < string , RefSpec > cachedRefSpecs = new ( ) ;
1518
1619 private IRepository RepositoryInstance
1720 {
@@ -28,10 +31,10 @@ private IRepository RepositoryInstance
2831 public IBranch Head => GetOrWrap ( RepositoryInstance . Head , RepositoryInstance . Diff ) ;
2932
3033 public ITagCollection Tags => new TagCollection ( RepositoryInstance . Tags , RepositoryInstance . Diff , this ) ;
31- public IReferenceCollection References => new ReferenceCollection ( RepositoryInstance . Refs ) ;
3234 public IBranchCollection Branches => new BranchCollection ( RepositoryInstance . Branches , RepositoryInstance . Diff , this ) ;
3335 public ICommitCollection Commits => new CommitCollection ( RepositoryInstance . Commits , RepositoryInstance . Diff , this ) ;
34- public IRemoteCollection Remotes => new RemoteCollection ( RepositoryInstance . Network . Remotes ) ;
36+ public IRemoteCollection Remotes => new RemoteCollection ( RepositoryInstance . Network . Remotes , this ) ;
37+ public IReferenceCollection References => new ReferenceCollection ( RepositoryInstance . Refs , this ) ;
3538
3639 public void DiscoverRepository ( string ? gitDirectory )
3740 {
@@ -65,23 +68,26 @@ public int UncommittedChangesCount()
6568
6669 public Branch GetOrWrap ( LibGit2Sharp . Branch innerBranch , Diff repoDiff )
6770 {
68- if ( innerBranch . Tip is null )
69- {
70- return new Branch ( innerBranch , repoDiff , this ) ;
71- }
72-
73- var cacheKey = $ "{ innerBranch . RemoteName } /{ innerBranch . CanonicalName } @{ innerBranch . Tip . Sha } ";
71+ var cacheKey = innerBranch . Tip is null
72+ ? $ "{ innerBranch . RemoteName } /{ innerBranch . CanonicalName } "
73+ : $ "{ innerBranch . RemoteName } /{ innerBranch . CanonicalName } @{ innerBranch . Tip . Sha } ";
7474 return cachedBranches . GetOrAdd ( cacheKey , _ => new Branch ( innerBranch , repoDiff , this ) ) ;
7575 }
7676
77- public Commit GetOrWrap ( LibGit2Sharp . Commit innerCommit , Diff repoDiff ) =>
78- cachedCommits . GetOrAdd ( innerCommit . Sha , _ => new Commit ( innerCommit , repoDiff , this ) ) ;
77+ public Commit GetOrWrap ( LibGit2Sharp . Commit innerCommit , Diff repoDiff )
78+ => cachedCommits . GetOrAdd ( innerCommit . Sha , _ => new Commit ( innerCommit , repoDiff , this ) ) ;
7979
8080 public Tag GetOrWrap ( LibGit2Sharp . Tag innerTag , Diff repoDiff )
81- {
82- var cacheKey = $ "{ innerTag . CanonicalName } @{ innerTag . Target . Sha } ";
83- return cachedTags . GetOrAdd ( cacheKey , _ => new Tag ( innerTag , repoDiff , this ) ) ;
84- }
81+ => cachedTags . GetOrAdd ( innerTag . CanonicalName , _ => new Tag ( innerTag , repoDiff , this ) ) ;
82+
83+ public Remote GetOrWrap ( LibGit2Sharp . Remote innerRemote )
84+ => cachedRemotes . GetOrAdd ( innerRemote . Name , _ => new Remote ( innerRemote , this ) ) ;
85+
86+ public Reference GetOrWrap ( LibGit2Sharp . Reference innerReference )
87+ => cachedReferences . GetOrAdd ( innerReference . CanonicalName , _ => new Reference ( innerReference ) ) ;
88+
89+ public RefSpec GetOrWrap ( LibGit2Sharp . RefSpec innerRefSpec )
90+ => cachedRefSpecs . GetOrAdd ( innerRefSpec . Specification , _ => new RefSpec ( innerRefSpec ) ) ;
8591
8692 public void Dispose ( )
8793 {
0 commit comments