(idx Index, hashes []plumbing.Hash)
| 80 | } |
| 81 | |
| 82 | func (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 | |
| 113 | func (e *Encoder) encodeFileHeader(chunkCount int) (err error) { |
| 114 | if _, err = e.Write(commitFileSignature); err == nil { |
no test coverage detected