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

Method prepare

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

Source from the content-addressed store, hash-verified

70}
71
72func (e *Encoder) prepare(idx Index, hashes []plumbing.Hash) (hashToIndex map[plumbing.Hash]uint32, fanout []uint32, extraEdgesCount uint32) {
73 // Sort the hashes and build our index
74 plumbing.HashesSort(hashes)
75 hashToIndex = make(map[plumbing.Hash]uint32)
76 fanout = make([]uint32, 256)
77 for i, hash := range hashes {
78 hashToIndex[hash] = uint32(i)
79 fanout[hash[0]]++
80 }
81
82 // Convert the fanout to cumulative values
83 for i := 1; i <= 0xff; i++ {
84 fanout[i] += fanout[i-1]
85 }
86
87 // Find out if we will need extra edge table
88 for i := 0; i < len(hashes); i++ {
89 v, _ := idx.GetCommitDataByIndex(i)
90 if len(v.ParentHashes) > 2 {
91 extraEdgesCount += uint32(len(v.ParentHashes) - 1)
92 break
93 }
94 }
95
96 return
97}
98
99func (e *Encoder) encodeFileHeader(chunkCount int) (err error) {
100 if _, err = e.Write(commitFileSignature); err == nil {

Callers 1

EncodeMethod · 0.95

Calls 2

HashesSortFunction · 0.92
GetCommitDataByIndexMethod · 0.65

Tested by

no test coverage detected