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

Commit b18457d

Browse files
committed
storage: some minor code cleanup
Suggested by mcuadros. Issue: #669
1 parent aa092f5 commit b18457d

File tree

3 files changed

+5
-13
lines changed

3 files changed

+5
-13
lines changed

prune.go

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ func (r *Repository) Prune(opt PruneOptions) error {
2828
return err
2929
}
3030
// Now walk all (loose) objects in storage.
31-
err = r.Storer.ForEachObjectHash(func(hash plumbing.Hash) error {
31+
return r.Storer.ForEachObjectHash(func(hash plumbing.Hash) error {
3232
// Get out if we have seen this object.
3333
if pw.isSeen(hash) {
3434
return nil
@@ -49,8 +49,4 @@ func (r *Repository) Prune(opt PruneOptions) error {
4949
}
5050
return opt.Handler(hash)
5151
})
52-
if err != nil {
53-
return err
54-
}
55-
return nil
5652
}

storage/filesystem/object.go

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -509,13 +509,10 @@ func hashListAsMap(l []plumbing.Hash) map[plumbing.Hash]bool {
509509

510510
func (s *ObjectStorage) ForEachObjectHash(fun func(plumbing.Hash) error) error {
511511
err := s.dir.ForEachObjectHash(fun)
512-
if err != nil {
513-
if err == storer.ErrStop {
514-
return nil
515-
}
516-
return err
512+
if err == storer.ErrStop {
513+
return nil
517514
}
518-
return nil
515+
return err
519516
}
520517

521518
func (s *ObjectStorage) LooseObjectTime(hash plumbing.Hash) (time.Time, error) {

storage/memory/storage.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,8 +116,7 @@ func (o *ObjectStorage) SetEncodedObject(obj plumbing.EncodedObject) (plumbing.H
116116
}
117117

118118
func (o *ObjectStorage) HasEncodedObject(h plumbing.Hash) (err error) {
119-
_, ok := o.Objects[h]
120-
if !ok {
119+
if _, ok := o.Objects[h]; !ok {
121120
return plumbing.ErrObjectNotFound
122121
}
123122
return nil

0 commit comments

Comments
 (0)