aboutsummaryrefslogtreecommitdiffstats
path: root/plumbing/format/commitgraph/commitgraph.go
diff options
context:
space:
mode:
authorMáximo Cuadros <mcuadros@gmail.com>2019-04-24 10:47:35 +0200
committerGitHub <noreply@github.com>2019-04-24 10:47:35 +0200
commit4a6229296f5d8991d46e581d331e4e889a5a87ec (patch)
treeb1118f3955c679de898fb861eed3af7465a1b40f /plumbing/format/commitgraph/commitgraph.go
parent44a20dee8209b22abdbfe226fba7f248a6a3eae0 (diff)
parentab5b89c4d4ba616ff125c3d489c1e5881c2dd14b (diff)
downloadgo-git-4a6229296f5d8991d46e581d331e4e889a5a87ec.tar.gz
Merge pull request #1128 from filipnavara/commitgraph-fmt
plumbing: format/commitgraph, add APIs for reading and writing commit-graph files
Diffstat (limited to 'plumbing/format/commitgraph/commitgraph.go')
-rw-r--r--plumbing/format/commitgraph/commitgraph.go35
1 files changed, 35 insertions, 0 deletions
diff --git a/plumbing/format/commitgraph/commitgraph.go b/plumbing/format/commitgraph/commitgraph.go
new file mode 100644
index 0000000..9bf7149
--- /dev/null
+++ b/plumbing/format/commitgraph/commitgraph.go
@@ -0,0 +1,35 @@
+package commitgraph
+
+import (
+ "time"
+
+ "gopkg.in/src-d/go-git.v4/plumbing"
+)
+
+// Node is a reduced representation of Commit as presented in the commit graph
+// file. It is merely useful as an optimization for walking the commit graphs.
+type Node struct {
+ // TreeHash is the hash of the root tree of the commit.
+ TreeHash plumbing.Hash
+ // ParentIndexes are the indexes of the parent commits of the commit.
+ ParentIndexes []int
+ // ParentHashes are the hashes of the parent commits of the commit.
+ ParentHashes []plumbing.Hash
+ // Generation number is the pre-computed generation in the commit graph
+ // or zero if not available
+ Generation int
+ // When is the timestamp of the commit.
+ When time.Time
+}
+
+// Index represents a representation of commit graph that allows indexed
+// access to the nodes using commit object hash
+type Index interface {
+ // GetIndexByHash gets the index in the commit graph from commit hash, if available
+ GetIndexByHash(h plumbing.Hash) (int, error)
+ // GetNodeByIndex gets the commit node from the commit graph using index
+ // obtained from child node, if available
+ GetNodeByIndex(i int) (*Node, error)
+ // Hashes returns all the hashes that are available in the index
+ Hashes() []plumbing.Hash
+}