hasIncomingObjects searches for an incoming directory and keeps its name so it doesn't have to be found each time an object is accessed.
()
| 593 | // hasIncomingObjects searches for an incoming directory and keeps its name |
| 594 | // so it doesn't have to be found each time an object is accessed. |
| 595 | func (d *DotGit) hasIncomingObjects() bool { |
| 596 | if !d.incomingChecked { |
| 597 | directoryContents, err := d.fs.ReadDir(objectsPath) |
| 598 | if err == nil { |
| 599 | for _, file := range directoryContents { |
| 600 | if file.IsDir() && (strings.HasPrefix(file.Name(), "tmp_objdir-incoming-") || |
| 601 | // Before Git 2.35 incoming commits directory had another prefix |
| 602 | strings.HasPrefix(file.Name(), "incoming-")) { |
| 603 | d.incomingDirName = file.Name() |
| 604 | } |
| 605 | } |
| 606 | } |
| 607 | |
| 608 | d.incomingChecked = true |
| 609 | } |
| 610 | |
| 611 | return d.incomingDirName != "" |
| 612 | } |
| 613 | |
| 614 | // Object returns a fs.File pointing the object file, if exists |
| 615 | func (d *DotGit) Object(h plumbing.Hash) (billy.File, error) { |
no test coverage detected