@@ -12,6 +12,8 @@ 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 , Reference > cachedReferences = new ( ) ;
16+ private readonly ConcurrentDictionary < string , Remote > cachedRemotes = new ( ) ;
1517
1618 private IRepository RepositoryInstance
1719 {
@@ -28,10 +30,10 @@ private IRepository RepositoryInstance
2830 public IBranch Head => GetOrWrap ( RepositoryInstance . Head , RepositoryInstance . Diff ) ;
2931
3032 public ITagCollection Tags => new TagCollection ( RepositoryInstance . Tags , RepositoryInstance . Diff , this ) ;
31- public IReferenceCollection Refs => new ReferenceCollection ( RepositoryInstance . Refs ) ;
33+ public IReferenceCollection Refs => new ReferenceCollection ( RepositoryInstance . Refs , this ) ;
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 ) ;
3537
3638 public void DiscoverRepository ( string ? gitDirectory )
3739 {
@@ -77,6 +79,12 @@ public Commit GetOrWrap(LibGit2Sharp.Commit innerCommit, Diff repoDiff)
7779 public Tag GetOrWrap ( LibGit2Sharp . Tag innerTag , Diff repoDiff )
7880 => cachedTags . GetOrAdd ( innerTag . CanonicalName , _ => new Tag ( innerTag , repoDiff , this ) ) ;
7981
82+ public Reference GetOrWrap ( LibGit2Sharp . Reference innerReference )
83+ => cachedReferences . GetOrAdd ( innerReference . CanonicalName , _ => new Reference ( innerReference ) ) ;
84+
85+ public Remote GetOrWrap ( LibGit2Sharp . Remote innerRemote )
86+ => cachedRemotes . GetOrAdd ( innerRemote . Name , _ => new Remote ( innerRemote ) ) ;
87+
8088 public void Dispose ( )
8189 {
8290 if ( this . repositoryLazy is { IsValueCreated : true } ) RepositoryInstance . Dispose ( ) ;
0 commit comments