aboutsummaryrefslogtreecommitdiffstats
path: root/storage
diff options
context:
space:
mode:
Diffstat (limited to 'storage')
-rw-r--r--storage/filesystem/object.go4
-rw-r--r--storage/filesystem/object_test.go14
2 files changed, 15 insertions, 3 deletions
diff --git a/storage/filesystem/object.go b/storage/filesystem/object.go
index d2ba411..6cd2d4c 100644
--- a/storage/filesystem/object.go
+++ b/storage/filesystem/object.go
@@ -205,9 +205,7 @@ func (s *ObjectStorage) encodedObjectSizeFromPackfile(h plumbing.Hash) (
if ok {
return obj.Size(), nil
}
- }
-
- if err != nil && err != plumbing.ErrObjectNotFound {
+ } else if err != nil && err != plumbing.ErrObjectNotFound {
return 0, err
}
diff --git a/storage/filesystem/object_test.go b/storage/filesystem/object_test.go
index 3a0cc4f..4e6bbfb 100644
--- a/storage/filesystem/object_test.go
+++ b/storage/filesystem/object_test.go
@@ -107,6 +107,20 @@ func (s *FsSuite) TestGetSizeFromPackfile(c *C) {
})
}
+func (s *FsSuite) TestGetSizeOfAllObjectFiles(c *C) {
+ fs := fixtures.ByTag(".git").One().DotGit()
+ o := NewObjectStorage(dotgit.New(fs), cache.NewObjectLRUDefault())
+
+ // Get the size of `tree_walker.go`.
+ err := o.ForEachObjectHash(func(h plumbing.Hash) error {
+ size, err := o.EncodedObjectSize(h)
+ c.Assert(err, IsNil)
+ c.Assert(size, Not(Equals), int64(0))
+ return nil
+ })
+ c.Assert(err, IsNil)
+}
+
func (s *FsSuite) TestGetFromPackfileMultiplePackfiles(c *C) {
fs := fixtures.ByTag(".git").ByTag("multi-packfile").One().DotGit()
o := NewObjectStorage(dotgit.New(fs), cache.NewObjectLRUDefault())