@@ -6,8 +6,10 @@ import (
66 "fmt"
77 "io"
88
9+ "gopkg.in/src-d/go-billy.v4/osfs"
910 "gopkg.in/src-d/go-git.v4/config"
1011 "gopkg.in/src-d/go-git.v4/plumbing"
12+ "gopkg.in/src-d/go-git.v4/plumbing/cache"
1113 "gopkg.in/src-d/go-git.v4/plumbing/format/packfile"
1214 "gopkg.in/src-d/go-git.v4/plumbing/object"
1315 "gopkg.in/src-d/go-git.v4/plumbing/protocol/packp"
@@ -18,6 +20,7 @@ import (
1820 "gopkg.in/src-d/go-git.v4/plumbing/transport"
1921 "gopkg.in/src-d/go-git.v4/plumbing/transport/client"
2022 "gopkg.in/src-d/go-git.v4/storage"
23+ "gopkg.in/src-d/go-git.v4/storage/filesystem"
2124 "gopkg.in/src-d/go-git.v4/storage/memory"
2225 "gopkg.in/src-d/go-git.v4/utils/ioutil"
2326)
@@ -149,7 +152,17 @@ func (r *Remote) PushContext(ctx context.Context, o *PushOptions) (err error) {
149152 var hashesToPush []plumbing.Hash
150153 // Avoid the expensive revlist operation if we're only doing deletes.
151154 if ! allDelete {
152- hashesToPush , err = revlist .Objects (r .s , objects , haves )
155+ if r .c .IsFirstURLLocal () {
156+ // If we're are pushing to a local repo, it might be much
157+ // faster to use a local storage layer to get the commits
158+ // to ignore, when calculating the object revlist.
159+ localStorer := filesystem .NewStorage (
160+ osfs .New (r .c .URLs [0 ]), cache .NewObjectLRUDefault ())
161+ hashesToPush , err = revlist .ObjectsWithStorageForIgnores (
162+ r .s , localStorer , objects , haves )
163+ } else {
164+ hashesToPush , err = revlist .Objects (r .s , objects , haves )
165+ }
153166 if err != nil {
154167 return err
155168 }
0 commit comments