diff options
author | Máximo Cuadros <mcuadros@gmail.com> | 2017-08-28 20:38:58 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-08-28 20:38:58 +0200 |
commit | 7aa9d15d395282144f31a09c0fac230da3f65360 (patch) | |
tree | 54675ba97a4b813e38630195e821b93553543098 /remote.go | |
parent | cb3272280ba9cbe8a3961e9244170129eb9a246b (diff) | |
parent | 467cb2aaa00ac30a8d2b5cc5b93951dad917ceb4 (diff) | |
download | go-git-7aa9d15d395282144f31a09c0fac230da3f65360.tar.gz |
Merge pull request #567 from strib/avoid-revlist-when-deletingv4.0.0-rc14
remote: avoid expensive revlist operation when only deleting refs
Diffstat (limited to 'remote.go')
-rw-r--r-- | remote.go | 15 |
1 files changed, 12 insertions, 3 deletions
@@ -92,9 +92,14 @@ func (r *Remote) PushContext(ctx context.Context, o *PushOptions) error { } isDelete := false + allDelete := true for _, rs := range o.RefSpecs { if rs.IsDelete() { isDelete = true + } else { + allDelete = false + } + if isDelete && !allDelete { break } } @@ -132,9 +137,13 @@ func (r *Remote) PushContext(ctx context.Context, o *PushOptions) error { // we are aware. haves = append(haves, stop...) - hashesToPush, err := revlist.Objects(r.s, objects, haves) - if err != nil { - return err + 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 err != nil { + return err + } } rs, err := pushHashes(ctx, s, r.s, req, hashesToPush) |