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