aboutsummaryrefslogtreecommitdiffstats
path: root/repository.go
diff options
context:
space:
mode:
authorTaru Karttunen <taruti@taruti.net>2017-11-21 17:39:24 +0200
committerJeremy Stribling <strib@alum.mit.edu>2017-11-29 11:01:41 -0800
commit2de4f034288bac895b0a87dcfb5cc3a2f9026f43 (patch)
tree05d2323eb76bcbd54e6ae6fad58fa97f93fda6da /repository.go
parentf28e4477dfe49a36dbd55027f8d1133c324bdac5 (diff)
downloadgo-git-2de4f034288bac895b0a87dcfb5cc3a2f9026f43.tar.gz
Use object walker in repacking code
Diffstat (limited to 'repository.go')
-rw-r--r--repository.go21
1 files changed, 9 insertions, 12 deletions
diff --git a/repository.go b/repository.go
index 1191b96..d96399b 100644
--- a/repository.go
+++ b/repository.go
@@ -1055,6 +1055,15 @@ func (r *Repository) RepackObjects(cfg *RepackConfig) (err error) {
// of creating a new pack. It is used so the the PackfileWriter
// deferred close has the right scope.
func (r *Repository) createNewObjectPack(cfg *RepackConfig) (h plumbing.Hash, err error) {
+ ow := newObjectWalker(r.Storer)
+ err = ow.walkAllRefs()
+ if err != nil {
+ return h, err
+ }
+ objs := make([]plumbing.Hash, 0, len(ow.seen))
+ for h := range ow.seen {
+ objs = append(objs, h)
+ }
pfw, ok := r.Storer.(storer.PackfileWriter)
if !ok {
return h, fmt.Errorf("Repository storer is not a storer.PackfileWriter")
@@ -1064,18 +1073,6 @@ func (r *Repository) createNewObjectPack(cfg *RepackConfig) (h plumbing.Hash, er
return h, err
}
defer ioutil.CheckClose(wc, &err)
- var objs []plumbing.Hash
- iter, err := r.Storer.IterEncodedObjects(plumbing.AnyObject)
- if err != nil {
- return h, err
- }
- err = iter.ForEach(func(obj plumbing.EncodedObject) error {
- objs = append(objs, obj.Hash())
- return nil
- })
- if err != nil {
- return h, err
- }
scfg, err := r.Storer.Config()
if err != nil {
return h, err