diff options
author | Jeremy Stribling <strib@alum.mit.edu> | 2019-02-08 12:39:12 -0800 |
---|---|---|
committer | Jeremy Stribling <strib@alum.mit.edu> | 2019-02-11 15:13:11 -0800 |
commit | 3889c6446da5f9d658b9bfe317429196e25aa4b7 (patch) | |
tree | a398b9df6d0d1afd13b6923393766a96b2a7af2d | |
parent | f56336220f6ac9b5647980953fe6df8bb53ae01e (diff) | |
download | go-git-3889c6446da5f9d658b9bfe317429196e25aa4b7.tar.gz |
remote: when pushing to a local repo, use local store for ignores
Issue: #909
Signed-off-by: Jeremy Stribling <strib@alum.mit.edu>
-rw-r--r-- | remote.go | 15 |
1 files changed, 14 insertions, 1 deletions
@@ -6,8 +6,10 @@ import ( "fmt" "io" + "gopkg.in/src-d/go-billy.v4/osfs" "gopkg.in/src-d/go-git.v4/config" "gopkg.in/src-d/go-git.v4/plumbing" + "gopkg.in/src-d/go-git.v4/plumbing/cache" "gopkg.in/src-d/go-git.v4/plumbing/format/packfile" "gopkg.in/src-d/go-git.v4/plumbing/object" "gopkg.in/src-d/go-git.v4/plumbing/protocol/packp" @@ -18,6 +20,7 @@ import ( "gopkg.in/src-d/go-git.v4/plumbing/transport" "gopkg.in/src-d/go-git.v4/plumbing/transport/client" "gopkg.in/src-d/go-git.v4/storage" + "gopkg.in/src-d/go-git.v4/storage/filesystem" "gopkg.in/src-d/go-git.v4/storage/memory" "gopkg.in/src-d/go-git.v4/utils/ioutil" ) @@ -149,7 +152,17 @@ func (r *Remote) PushContext(ctx context.Context, o *PushOptions) (err error) { var hashesToPush []plumbing.Hash // Avoid the expensive revlist operation if we're only doing deletes. if !allDelete { - hashesToPush, err = revlist.Objects(r.s, objects, haves) + if r.c.IsFirstURLLocal() { + // If we're are pushing to a local repo, it might be much + // faster to use a local storage layer to get the commits + // to ignore, when calculating the object revlist. + localStorer := filesystem.NewStorage( + osfs.New(r.c.URLs[0]), cache.NewObjectLRUDefault()) + hashesToPush, err = revlist.ObjectsWithStorageForIgnores( + r.s, localStorer, objects, haves) + } else { + hashesToPush, err = revlist.Objects(r.s, objects, haves) + } if err != nil { return err } |