go-git: github.com/go-git/go-git/plumbing/object/commitgraph Index | Files

package commitgraph

import "github.com/go-git/go-git/plumbing/object/commitgraph"

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.


Package Files

commitnode.go commitnode_graph.go commitnode_object.go commitnode_walker_ctime.go doc.go

type CommitNode Uses

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 Commiter.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
    // 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 Uses

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 Uses

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 Uses

func NewObjectCommitNodeIndex(s storer.EncodedObjectStorer) CommitNodeIndex

NewObjectCommitNodeIndex returns CommitNodeIndex implementation that uses only object storage to load the nodes

type CommitNodeIter Uses

type CommitNodeIter interface {
    Next() (CommitNode, error)
    ForEach(func(CommitNode) error) error

CommitNodeIter is a generic closable interface for iterating over commit nodes.

func NewCommitNodeIterCTime Uses

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 appears to be the closest order to `git log` 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.

Package commitgraph imports 9 packages (graph). Updated 2020-11-28. Refresh now. Tools for package owners.