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

Method loadIdxFile

storage/filesystem/object.go:78–99  ·  view source on GitHub ↗
(h plumbing.Hash)

Source from the content-addressed store, hash-verified

76}
77
78func (s *ObjectStorage) loadIdxFile(h plumbing.Hash) (err error) {
79 f, err := s.dir.ObjectPackIdx(h)
80 if err != nil {
81 return err
82 }
83
84 defer ioutil.CheckClose(f, &err)
85
86 idxf := idxfile.NewMemoryIndex()
87 d := idxfile.NewDecoder(f)
88 if err = d.Decode(idxf); err != nil {
89 return err
90 }
91
92 if !bytes.Equal(idxf.PackfileChecksum[:], h[:]) {
93 return fmt.Errorf("%w: packfile mismatch: target is %q not %q",
94 idxfile.ErrMalformedIdxFile, hex.EncodeToString(idxf.PackfileChecksum[:]), h.String())
95 }
96
97 s.index[h] = idxf
98 return err
99}
100
101func (s *ObjectStorage) NewEncodedObject() plumbing.EncodedObject {
102 return &plumbing.MemoryObject{}

Callers 1

requireIndexMethod · 0.95

Calls 6

DecodeMethod · 0.95
CheckCloseFunction · 0.92
NewMemoryIndexFunction · 0.92
NewDecoderFunction · 0.92
ObjectPackIdxMethod · 0.80
StringMethod · 0.65

Tested by

no test coverage detected