@@ -7,6 +7,7 @@ namespace GitVersion.Git;
7
7
internal sealed partial class GitRepository
8
8
{
9
9
private Lazy < IRepository > ? repositoryLazy ;
10
+ private readonly GitCache gitCache = new ( ) ;
10
11
11
12
private IRepository RepositoryInstance
12
13
{
@@ -20,13 +21,13 @@ private IRepository RepositoryInstance
20
21
public string WorkingDirectory => RepositoryInstance . Info . WorkingDirectory ;
21
22
public bool IsHeadDetached => RepositoryInstance . Info . IsHeadDetached ;
22
23
public bool IsShallow => RepositoryInstance . Info . IsShallow ;
23
- public IBranch Head => new Branch ( RepositoryInstance . Head , RepositoryInstance . Diff ) ;
24
+ public IBranch Head => this . gitCache . GetOrCreate ( RepositoryInstance . Head , RepositoryInstance . Diff ) ;
24
25
25
- public ITagCollection Tags => new TagCollection ( RepositoryInstance . Tags , RepositoryInstance . Diff ) ;
26
- public IReferenceCollection Refs => new ReferenceCollection ( RepositoryInstance . Refs ) ;
27
- public IBranchCollection Branches => new BranchCollection ( RepositoryInstance . Branches , RepositoryInstance . Diff ) ;
28
- public ICommitCollection Commits => new CommitCollection ( RepositoryInstance . Commits , RepositoryInstance . Diff ) ;
29
- public IRemoteCollection Remotes => new RemoteCollection ( RepositoryInstance . Network . Remotes ) ;
26
+ public ITagCollection Tags => new TagCollection ( RepositoryInstance . Tags , RepositoryInstance . Diff , this . gitCache ) ;
27
+ public IReferenceCollection Refs => new ReferenceCollection ( RepositoryInstance . Refs , this . gitCache ) ;
28
+ public IBranchCollection Branches => new BranchCollection ( RepositoryInstance . Branches , RepositoryInstance . Diff , this . gitCache ) ;
29
+ public ICommitCollection Commits => new CommitCollection ( RepositoryInstance . Commits , RepositoryInstance . Diff , this . gitCache ) ;
30
+ public IRemoteCollection Remotes => new RemoteCollection ( RepositoryInstance . Network . Remotes , this . gitCache ) ;
30
31
31
32
public void DiscoverRepository ( string ? gitDirectory )
32
33
{
@@ -48,7 +49,7 @@ public void DiscoverRepository(string? gitDirectory)
48
49
var first = ( Commit ) commit ;
49
50
var second = ( Commit ) otherCommit ;
50
51
var mergeBase = RepositoryInstance . ObjectDatabase . FindMergeBase ( first , second ) ;
51
- return mergeBase == null ? null : new Commit ( mergeBase , RepositoryInstance . Diff ) ;
52
+ return mergeBase == null ? null : this . gitCache . GetOrCreate ( mergeBase , RepositoryInstance . Diff ) ;
52
53
} ) ;
53
54
}
54
55
0 commit comments