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

Method objectPackOpen

storage/filesystem/dotgit/dotgit.go:274–306  ·  view source on GitHub ↗
(hash plumbing.Hash, extension string)

Source from the content-addressed store, hash-verified

272}
273
274func (d *DotGit) objectPackOpen(hash plumbing.Hash, extension string) (billy.File, error) {
275 if d.options.KeepDescriptors && extension == "pack" {
276 if d.files == nil {
277 d.files = make(map[plumbing.Hash]billy.File)
278 }
279
280 f, ok := d.files[hash]
281 if ok {
282 return f, nil
283 }
284 }
285
286 err := d.hasPack(hash)
287 if err != nil {
288 return nil, err
289 }
290
291 path := d.objectPackPath(hash, extension)
292 pack, err := d.fs.Open(path)
293 if err != nil {
294 if os.IsNotExist(err) {
295 return nil, ErrPackfileNotFound
296 }
297
298 return nil, err
299 }
300
301 if d.options.KeepDescriptors && extension == "pack" {
302 d.files[hash] = pack
303 }
304
305 return pack, nil
306}
307
308// ObjectPack returns a fs.File of the given packfile
309func (d *DotGit) ObjectPack(hash plumbing.Hash) (billy.File, error) {

Callers 2

ObjectPackMethod · 0.95
ObjectPackIdxMethod · 0.95

Calls 3

hasPackMethod · 0.95
objectPackPathMethod · 0.95
OpenMethod · 0.45

Tested by

no test coverage detected