@@ -6,8 +6,10 @@ import (
6
6
"fmt"
7
7
"io"
8
8
9
+ "gopkg.in/src-d/go-billy.v4/osfs"
9
10
"gopkg.in/src-d/go-git.v4/config"
10
11
"gopkg.in/src-d/go-git.v4/plumbing"
12
+ "gopkg.in/src-d/go-git.v4/plumbing/cache"
11
13
"gopkg.in/src-d/go-git.v4/plumbing/format/packfile"
12
14
"gopkg.in/src-d/go-git.v4/plumbing/object"
13
15
"gopkg.in/src-d/go-git.v4/plumbing/protocol/packp"
@@ -18,6 +20,7 @@ import (
18
20
"gopkg.in/src-d/go-git.v4/plumbing/transport"
19
21
"gopkg.in/src-d/go-git.v4/plumbing/transport/client"
20
22
"gopkg.in/src-d/go-git.v4/storage"
23
+ "gopkg.in/src-d/go-git.v4/storage/filesystem"
21
24
"gopkg.in/src-d/go-git.v4/storage/memory"
22
25
"gopkg.in/src-d/go-git.v4/utils/ioutil"
23
26
)
@@ -149,7 +152,17 @@ func (r *Remote) PushContext(ctx context.Context, o *PushOptions) (err error) {
149
152
var hashesToPush []plumbing.Hash
150
153
// Avoid the expensive revlist operation if we're only doing deletes.
151
154
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
+ }
153
166
if err != nil {
154
167
return err
155
168
}
0 commit comments