Objects returns a slice with the hashes of objects found under the .git/objects/ directory.
()
| 396 | // Objects returns a slice with the hashes of objects found under the |
| 397 | // .git/objects/ directory. |
| 398 | func (d *DotGit) Objects() ([]plumbing.Hash, error) { |
| 399 | if d.options.ExclusiveAccess { |
| 400 | err := d.genObjectList() |
| 401 | if err != nil { |
| 402 | return nil, err |
| 403 | } |
| 404 | |
| 405 | return d.objectList, nil |
| 406 | } |
| 407 | |
| 408 | var objects []plumbing.Hash |
| 409 | err := d.ForEachObjectHash(func(hash plumbing.Hash) error { |
| 410 | objects = append(objects, hash) |
| 411 | return nil |
| 412 | }) |
| 413 | if err != nil { |
| 414 | return nil, err |
| 415 | } |
| 416 | return objects, nil |
| 417 | } |
| 418 | |
| 419 | // ForEachObjectHash iterates over the hashes of objects found under the |
| 420 | // .git/objects/ directory and executes the provided function. |