MCPcopy Index your code
hub / github.com/go-git/go-git / Get

Method Get

plumbing/object/commitgraph/commitnode_graph.go:43–72  ·  view source on GitHub ↗
(hash plumbing.Hash)

Source from the content-addressed store, hash-verified

41}
42
43func (gci *graphCommitNodeIndex) Get(hash plumbing.Hash) (CommitNode, error) {
44 if gci.commitGraph != nil {
45 // Check the commit graph first
46 parentIndex, err := gci.commitGraph.GetIndexByHash(hash)
47 if err == nil {
48 parent, err := gci.commitGraph.GetCommitDataByIndex(parentIndex)
49 if err != nil {
50 return nil, err
51 }
52
53 return &graphCommitNode{
54 hash: hash,
55 index: parentIndex,
56 commitData: parent,
57 gci: gci,
58 }, nil
59 }
60 }
61
62 // Fallback to loading full commit object
63 commit, err := object.GetCommit(gci.s, hash)
64 if err != nil {
65 return nil, err
66 }
67
68 return &objectCommitNode{
69 nodeIndex: gci,
70 commit: commit,
71 }, nil
72}
73
74func (c *graphCommitNode) ID() plumbing.Hash {
75 return c.hash

Callers

nothing calls this directly

Calls 3

GetCommitFunction · 0.92
GetIndexByHashMethod · 0.65
GetCommitDataByIndexMethod · 0.65

Tested by

no test coverage detected