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

Method HasEncodedObject

storage/filesystem/object.go:164–186  ·  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

162// HasEncodedObject returns nil if the object exists, without actually
163// reading the object data from storage.
164func (s *ObjectStorage) HasEncodedObject(h plumbing.Hash) (err error) {
165 // Check unpacked objects
166 f, err := s.dir.Object(h)
167 if err != nil {
168 if !os.IsNotExist(err) {
169 return err
170 }
171 // Fall through to check packed objects.
172 } else {
173 defer ioutil.CheckClose(f, &err)
174 return nil
175 }
176
177 // Check packed objects.
178 if err := s.requireIndex(); err != nil {
179 return err
180 }
181 _, _, offset := s.findObjectInPackfile(h)
182 if offset == -1 {
183 return plumbing.ErrObjectNotFound
184 }
185 return nil
186}
187
188func (s *ObjectStorage) encodedObjectSizeFromUnpacked(h plumbing.Hash) (
189 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