This repository was archived by the owner on Sep 11, 2020. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +18
-0
lines changed Expand file tree Collapse file tree 3 files changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -25,6 +25,9 @@ type CommitNode interface {
2525 ParentNode (i int ) (CommitNode , error )
2626 // ParentHashes returns hashes of the parent commits for a specified node
2727 ParentHashes () []plumbing.Hash
28+ // Generation returns the generation of the commit for reachability analysis.
29+ // Objects with newer generation are not reachable from objects of older generation.
30+ Generation () uint64
2831 // Commit returns the full commit object from the node
2932 Commit () (* Commit , error )
3033}
Original file line number Diff line number Diff line change @@ -110,6 +110,13 @@ func (c *graphCommitNode) ParentHashes() []plumbing.Hash {
110110 return c .commitData .ParentHashes
111111}
112112
113+ func (c * graphCommitNode ) Generation () uint64 {
114+ // If the commit-graph file was generated with older Git version that
115+ // set the generation to zero for every commit the generation assumption
116+ // is still valid. It is just less useful.
117+ return uint64 (c .commitData .Generation )
118+ }
119+
113120func (c * graphCommitNode ) Commit () (* Commit , error ) {
114121 return GetCommit (c .gci .s , c .hash )
115122}
Original file line number Diff line number Diff line change 11package object
22
33import (
4+ "math"
45 "time"
56
67 "gopkg.in/src-d/go-git.v4/plumbing"
@@ -76,6 +77,13 @@ func (c *objectCommitNode) ParentHashes() []plumbing.Hash {
7677 return c .commit .ParentHashes
7778}
7879
80+ func (c * objectCommitNode ) Generation () uint64 {
81+ // Commit nodes representing objects outside of the commit graph can never
82+ // be reached by objects from the commit-graph thus we return the highest
83+ // possible value.
84+ return math .MaxUint64
85+ }
86+
7987func (c * objectCommitNode ) Commit () (* Commit , error ) {
8088 return c .commit , nil
8189}
You can’t perform that action at this time.
0 commit comments