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

Method Decode

plumbing/format/idxfile/decoder.go:37–58  ·  view source on GitHub ↗

Decode reads from the stream and decode the content into the MemoryIndex struct.

(idx *MemoryIndex)

Source from the content-addressed store, hash-verified

35
36// Decode reads from the stream and decode the content into the MemoryIndex struct.
37func (d *Decoder) Decode(idx *MemoryIndex) error {
38 if err := validateHeader(d); err != nil {
39 return err
40 }
41
42 flow := []func(*MemoryIndex, io.Reader) error{
43 readVersion,
44 readFanout,
45 readObjectNames,
46 readCRC32,
47 readOffsets,
48 readChecksums,
49 }
50
51 for _, f := range flow {
52 if err := f(idx, d); err != nil {
53 return err
54 }
55 }
56
57 return nil
58}
59
60func validateHeader(r io.Reader) error {
61 var h = make([]byte, 4)

Callers 5

fixtureIndexFunction · 0.95
TestDecodeEncodeMethod · 0.95
TestDecodeMethod · 0.95
BenchmarkDecodeFunction · 0.95

Calls 1

validateHeaderFunction · 0.70

Tested by 5

fixtureIndexFunction · 0.76
TestDecodeEncodeMethod · 0.76
TestDecodeMethod · 0.76
BenchmarkDecodeFunction · 0.76