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

Method prepare

plumbing/format/commitgraph/v2/encoder.go:82–111  ·  view source on GitHub ↗
(idx Index, hashes []plumbing.Hash)

Source from the content-addressed store, hash-verified

80}
81
82func (e *Encoder) prepare(idx Index, hashes []plumbing.Hash) (hashToIndex map[plumbing.Hash]uint32, fanout []uint32, extraEdgesCount uint32, generationV2OverflowCount uint32) {
83 // Sort the hashes and build our index
84 plumbing.HashesSort(hashes)
85 hashToIndex = make(map[plumbing.Hash]uint32)
86 fanout = make([]uint32, lenFanout)
87 for i, hash := range hashes {
88 hashToIndex[hash] = uint32(i)
89 fanout[hash[0]]++
90 }
91
92 // Convert the fanout to cumulative values
93 for i := 1; i < lenFanout; i++ {
94 fanout[i] += fanout[i-1]
95 }
96
97 hasGenerationV2 := idx.HasGenerationV2()
98
99 // Find out if we will need extra edge table
100 for i := 0; i < len(hashes); i++ {
101 v, _ := idx.GetCommitDataByIndex(uint32(i))
102 if len(v.ParentHashes) > 2 {
103 extraEdgesCount += uint32(len(v.ParentHashes) - 1)
104 }
105 if hasGenerationV2 && v.GenerationV2Data() > math.MaxUint32 {
106 generationV2OverflowCount++
107 }
108 }
109
110 return
111}
112
113func (e *Encoder) encodeFileHeader(chunkCount int) (err error) {
114 if _, err = e.Write(commitFileSignature); err == nil {

Callers 1

EncodeMethod · 0.95

Calls 4

HashesSortFunction · 0.92
GenerationV2DataMethod · 0.80
HasGenerationV2Method · 0.65
GetCommitDataByIndexMethod · 0.65

Tested by

no test coverage detected