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

Method forEachObjectHash

storage/filesystem/dotgit/dotgit.go:448–481  ·  view source on GitHub ↗
(fun func(plumbing.Hash) error)

Source from the content-addressed store, hash-verified

446}
447
448func (d *DotGit) forEachObjectHash(fun func(plumbing.Hash) error) error {
449 files, err := d.fs.ReadDir(objectsPath)
450 if err != nil {
451 if os.IsNotExist(err) {
452 return nil
453 }
454
455 return err
456 }
457
458 for _, f := range files {
459 if f.IsDir() && len(f.Name()) == 2 && isHex(f.Name()) {
460 base := f.Name()
461 d, err := d.fs.ReadDir(d.fs.Join(objectsPath, base))
462 if err != nil {
463 return err
464 }
465
466 for _, o := range d {
467 h := plumbing.NewHash(base + o.Name())
468 if h.IsZero() {
469 // Ignore files with badly-formatted names.
470 continue
471 }
472 err = fun(h)
473 if err != nil {
474 return err
475 }
476 }
477 }
478 }
479
480 return nil
481}
482
483func (d *DotGit) cleanObjectList() {
484 d.objectMap = nil

Callers 2

ForEachObjectHashMethod · 0.95
genObjectListMethod · 0.95

Calls 7

IsZeroMethod · 0.95
NewHashFunction · 0.92
isHexFunction · 0.85
JoinMethod · 0.80
IsDirMethod · 0.65
NameMethod · 0.65
ReadDirMethod · 0.45

Tested by

no test coverage detected