@@ -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 {
@@ -30,8 +33,8 @@ private IRepository RepositoryInstance
3033 public ITagCollection Tags => new TagCollection ( RepositoryInstance . Tags , RepositoryInstance . Diff , this ) ;
3134 public IBranchCollection Branches => new BranchCollection ( RepositoryInstance . Branches , RepositoryInstance . Diff , this ) ;
3235 public ICommitCollection Commits => new CommitCollection ( RepositoryInstance . Commits , RepositoryInstance . Diff , this ) ;
33- public IRemoteCollection Remotes => new RemoteCollection ( RepositoryInstance . Network . Remotes ) ;
34- public IReferenceCollection References => new ReferenceCollection ( RepositoryInstance . Refs ) ;
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 {
@@ -77,6 +80,15 @@ public Commit GetOrCreate(LibGit2Sharp.Commit innerCommit, Diff repoDiff)
7780 public Tag GetOrCreate ( LibGit2Sharp . Tag innerTag , Diff repoDiff )
7881 => cachedTags . GetOrAdd ( innerTag . CanonicalName , _ => new Tag ( innerTag , repoDiff , this ) ) ;
7982
83+ public Remote GetOrCreate ( LibGit2Sharp . Remote innerRemote )
84+ => cachedRemotes . GetOrAdd ( innerRemote . Name , _ => new Remote ( innerRemote , this ) ) ;
85+
86+ public Reference GetOrCreate ( LibGit2Sharp . Reference innerReference )
87+ => cachedReferences . GetOrAdd ( innerReference . CanonicalName , _ => new Reference ( innerReference ) ) ;
88+
89+ public RefSpec GetOrCreate ( LibGit2Sharp . RefSpec innerRefSpec )
90+ => cachedRefSpecs . GetOrAdd ( innerRefSpec . Specification , _ => new RefSpec ( innerRefSpec ) ) ;
91+
8092 public void Dispose ( )
8193 {
8294 if ( this . repositoryLazy is { IsValueCreated : true } ) RepositoryInstance . Dispose ( ) ;
0 commit comments