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

Method Encode

plumbing/format/idxfile/encoder.go:24–45  ·  view source on GitHub ↗

Encode encodes an MemoryIndex to the encoder writer.

(idx *MemoryIndex)

Source from the content-addressed store, hash-verified

22
23// Encode encodes an MemoryIndex to the encoder writer.
24func (e *Encoder) Encode(idx *MemoryIndex) (int, error) {
25 flow := []func(*MemoryIndex) (int, error){
26 e.encodeHeader,
27 e.encodeFanout,
28 e.encodeHashes,
29 e.encodeCRC32,
30 e.encodeOffsets,
31 e.encodeChecksums,
32 }
33
34 sz := 0
35 for _, f := range flow {
36 i, err := f(idx)
37 sz += i
38
39 if err != nil {
40 return sz, err
41 }
42 }
43
44 return sz, nil
45}
46
47func (e *Encoder) encodeHeader(idx *MemoryIndex) (int, error) {
48 c, err := e.Write(idxHeader)

Callers 3

TestWriterMethod · 0.95
TestWriterLargeMethod · 0.95
TestDecodeEncodeMethod · 0.95

Calls

no outgoing calls

Tested by 3

TestWriterMethod · 0.76
TestWriterLargeMethod · 0.76
TestDecodeEncodeMethod · 0.76