MCPcopy Create free account
hub / github.com/go-git/go-git / Add

Method Add

plumbing/format/commitgraph/v2/memory.go:83–94  ·  view source on GitHub ↗

Add adds new node to the memory index

(hash plumbing.Hash, data *CommitData)

Source from the content-addressed store, hash-verified

81
82// Add adds new node to the memory index
83func (mi *MemoryIndex) Add(hash plumbing.Hash, data *CommitData) {
84 // The parent indexes are calculated lazily in GetNodeByIndex
85 // which allows adding nodes out of order as long as all parents
86 // are eventually resolved
87 data.ParentIndexes = nil
88 mi.indexMap[hash] = uint32(len(mi.commitData))
89 mi.commitData = append(mi.commitData, commitData{Hash: hash, CommitData: data})
90 if data.GenerationV2 == math.MaxUint64 { // if GenerationV2 is not available reset it to zero
91 data.GenerationV2 = 0
92 }
93 mi.hasGenerationV2 = mi.hasGenerationV2 && data.GenerationV2 != 0
94}
95
96func (mi *MemoryIndex) HasGenerationV2() bool {
97 return mi.hasGenerationV2

Callers 1

TestReencodeInMemoryMethod · 0.95

Calls

no outgoing calls

Tested by 1

TestReencodeInMemoryMethod · 0.76