Skip to content
This repository was archived by the owner on Sep 11, 2020. It is now read-only.

Commit beb994d

Browse files
committed
Search packfile indexes first if we already loaded them.
Signed-off-by: Filip Navara <[email protected]>
1 parent ac7c466 commit beb994d

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

storage/filesystem/object.go

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,9 +166,19 @@ func (s *ObjectStorage) HasEncodedObject(h plumbing.Hash) (err error) {
166166
// EncodedObject returns the object with the given hash, by searching for it in
167167
// the packfile and the git object directories.
168168
func (s *ObjectStorage) EncodedObject(t plumbing.ObjectType, h plumbing.Hash) (plumbing.EncodedObject, error) {
169-
obj, err := s.getFromUnpacked(h)
170-
if err == plumbing.ErrObjectNotFound {
169+
var obj plumbing.EncodedObject
170+
var err error
171+
172+
if s.index != nil {
171173
obj, err = s.getFromPackfile(h, false)
174+
if err == plumbing.ErrObjectNotFound {
175+
obj, err = s.getFromUnpacked(h)
176+
}
177+
} else {
178+
obj, err = s.getFromUnpacked(h)
179+
if err == plumbing.ErrObjectNotFound {
180+
obj, err = s.getFromPackfile(h, false)
181+
}
172182
}
173183

174184
// If the error is still object not found, check if it's a shared object

0 commit comments

Comments
 (0)