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

Method objectPackOpen

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

Source from the content-addressed store, hash-verified

265}
266
267func (d *DotGit) objectPackOpen(hash plumbing.Hash, extension string) (billy.File, error) {
268 if d.options.KeepDescriptors && extension == "pack" {
269 if d.files == nil {
270 d.files = make(map[plumbing.Hash]billy.File)
271 }
272
273 f, ok := d.files[hash]
274 if ok {
275 return f, nil
276 }
277 }
278
279 err := d.hasPack(hash)
280 if err != nil {
281 return nil, err
282 }
283
284 path := d.objectPackPath(hash, extension)
285 pack, err := d.fs.Open(path)
286 if err != nil {
287 if os.IsNotExist(err) {
288 return nil, ErrPackfileNotFound
289 }
290
291 return nil, err
292 }
293
294 if d.options.KeepDescriptors && extension == "pack" {
295 d.files[hash] = pack
296 }
297
298 return pack, nil
299}
300
301// ObjectPack returns a fs.File of the given packfile
302func (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