Documentation
¶
Overview ¶
Package commitgraph provides an interface for efficient traversal over Git commit graph either through the regular object storage, or optionally with the index stored in commit-graph file (Git 2.18+).
The API and functionality of this package are considered EXPERIMENTAL and is not considered stable nor production ready.
Index ¶
- type CommitNode
- type CommitNodeIndex
- type CommitNodeIter
- func NewCommitNodeIterAuthorDateOrder(c CommitNode, seenExternal map[plumbing.Hash]bool, ignore []plumbing.Hash) CommitNodeIter
- func NewCommitNodeIterCTime(c CommitNode, seenExternal map[plumbing.Hash]bool, ignore []plumbing.Hash) CommitNodeIter
- func NewCommitNodeIterDateOrder(c CommitNode, seenExternal map[plumbing.Hash]bool, ignore []plumbing.Hash) CommitNodeIter
- func NewCommitNodeIterTopoOrder(c CommitNode, seenExternal map[plumbing.Hash]bool, ignore []plumbing.Hash) CommitNodeIter
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CommitNode ¶
type CommitNode interface { // ID returns the Commit object id referenced by the commit graph node. ID() plumbing.Hash // Tree returns the Tree referenced by the commit graph node. Tree() (*object.Tree, error) // CommitTime returns the Committer.When time of the Commit referenced by the commit graph node. CommitTime() time.Time // NumParents returns the number of parents in a commit. NumParents() int // ParentNodes return a CommitNodeIter for parents of specified node. ParentNodes() CommitNodeIter // ParentNode returns the ith parent of a commit. ParentNode(i int) (CommitNode, error) // ParentHashes returns hashes of the parent commits for a specified node ParentHashes() []plumbing.Hash // Generation returns the generation of the commit for reachability analysis. // Objects with newer generation are not reachable from objects of older generation. Generation() uint64 // GenerationV2 stores the corrected commit date for the commits // It combines the contents of the GDA2 and GDO2 sections of the commit-graph // with the commit time portion of the CDAT section. GenerationV2() uint64 // Commit returns the full commit object from the node Commit() (*object.Commit, error) }
CommitNode is generic interface encapsulating a lightweight commit object retrieved from CommitNodeIndex
type CommitNodeIndex ¶
type CommitNodeIndex interface { // Get returns a commit node from a commit hash Get(hash plumbing.Hash) (CommitNode, error) }
CommitNodeIndex is generic interface encapsulating an index of CommitNode objects
func NewGraphCommitNodeIndex ¶
func NewGraphCommitNodeIndex(commitGraph commitgraph.Index, s storer.EncodedObjectStorer) CommitNodeIndex
NewGraphCommitNodeIndex returns CommitNodeIndex implementation that uses commit-graph files as backing storage and falls back to object storage when necessary
func NewObjectCommitNodeIndex ¶
func NewObjectCommitNodeIndex(s storer.EncodedObjectStorer) CommitNodeIndex
NewObjectCommitNodeIndex returns CommitNodeIndex implementation that uses only object storage to load the nodes
type CommitNodeIter ¶
type CommitNodeIter interface { Next() (CommitNode, error) ForEach(func(CommitNode) error) error Close() }
CommitNodeIter is a generic closable interface for iterating over commit nodes.
func NewCommitNodeIterAuthorDateOrder ¶
func NewCommitNodeIterAuthorDateOrder(c CommitNode, seenExternal map[plumbing.Hash]bool, ignore []plumbing.Hash, ) CommitNodeIter
NewCommitNodeIterAuthorDateOrder returns a CommitNodeIter that walks the commit history, starting at the given commit and visiting its parents in Author Time order but with the constraint that no parent is emitted before its children are emitted.
This matches `git log --author-order`
This ordering requires that commit objects need to be loaded into memory - thus this ordering is likely to be slower than other orderings.
func NewCommitNodeIterCTime ¶
func NewCommitNodeIterCTime( c CommitNode, seenExternal map[plumbing.Hash]bool, ignore []plumbing.Hash, ) CommitNodeIter
NewCommitNodeIterCTime returns a CommitNodeIter that walks the commit history, starting at the given commit and visiting its parents while preserving Committer Time order. this is close in order to `git log` but does not guarantee topological order and will order things incorrectly occasionally. The given callback will be called for each visited commit. Each commit will be visited only once. If the callback returns an error, walking will stop and will return the error. Other errors might be returned if the history cannot be traversed (e.g. missing objects). Ignore allows to skip some commits from being iterated.
func NewCommitNodeIterDateOrder ¶
func NewCommitNodeIterDateOrder(c CommitNode, seenExternal map[plumbing.Hash]bool, ignore []plumbing.Hash, ) CommitNodeIter
NewCommitNodeIterDateOrder returns a CommitNodeIter that walks the commit history, starting at the given commit and visiting its parents in Committer Time and Generation order, but with the constraint that no parent is emitted before its children are emitted.
This matches `git log --date-order`
func NewCommitNodeIterTopoOrder ¶
func NewCommitNodeIterTopoOrder(c CommitNode, seenExternal map[plumbing.Hash]bool, ignore []plumbing.Hash, ) CommitNodeIter
NewCommitNodeIterTopoOrder returns a CommitNodeIter that walks the commit history, starting at the given commit and visiting its parents in a topological order but with the constraint that no parent is emitted before its children are emitted.
This matches `git log --topo-order`