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

Method HasEncodedObject

storage/filesystem/object.go:171–193  ·  view source on GitHub ↗

HasEncodedObject returns nil if the object exists, without actually reading the object data from storage.

(h plumbing.Hash)

Source from the content-addressed store, hash-verified

169// HasEncodedObject returns nil if the object exists, without actually
170// reading the object data from storage.
171func (s *ObjectStorage) HasEncodedObject(h plumbing.Hash) (err error) {
172 // Check unpacked objects
173 f, err := s.dir.Object(h)
174 if err != nil {
175 if !os.IsNotExist(err) {
176 return err
177 }
178 // Fall through to check packed objects.
179 } else {
180 defer ioutil.CheckClose(f, &err)
181 return nil
182 }
183
184 // Check packed objects.
185 if err := s.requireIndex(); err != nil {
186 return err
187 }
188 _, _, offset := s.findObjectInPackfile(h)
189 if offset == -1 {
190 return plumbing.ErrObjectNotFound
191 }
192 return nil
193}
194
195func (s *ObjectStorage) encodedObjectSizeFromUnpacked(h plumbing.Hash) (
196 size int64, err error,

Callers

nothing calls this directly

Calls 4

requireIndexMethod · 0.95
findObjectInPackfileMethod · 0.95
CheckCloseFunction · 0.92
ObjectMethod · 0.45

Tested by

no test coverage detected