diff options
author | Máximo Cuadros <mcuadros@gmail.com> | 2018-10-17 12:01:47 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-10-17 12:01:47 +0200 |
commit | f2a7dad17c6fdc7e6c9a99bac8a6d09ec1c71c01 (patch) | |
tree | adfe885d83e3a33003e7f4c37ec29077c0002cfe /remote.go | |
parent | 1a2248b4463cfd4c0e7377150448069d1969fc22 (diff) | |
parent | 1618e1cf321aa9cee6d0c11cb14e265b049563c4 (diff) | |
download | go-git-f2a7dad17c6fdc7e6c9a99bac8a6d09ec1c71c01.tar.gz |
Merge pull request #987 from bashims/945-push-ref-deltas
remote: use reference deltas on push when the remote server does not …
Diffstat (limited to 'remote.go')
-rw-r--r-- | remote.go | 9 |
1 files changed, 7 insertions, 2 deletions
@@ -155,7 +155,7 @@ func (r *Remote) PushContext(ctx context.Context, o *PushOptions) (err error) { } } - rs, err := pushHashes(ctx, s, r.s, req, hashesToPush) + rs, err := pushHashes(ctx, s, r.s, req, hashesToPush, r.useRefDeltas(ar)) if err != nil { return err } @@ -167,6 +167,10 @@ func (r *Remote) PushContext(ctx context.Context, o *PushOptions) (err error) { return r.updateRemoteReferenceStorage(req, rs) } +func (r *Remote) useRefDeltas(ar *packp.AdvRefs) bool { + return !ar.Capabilities.Supports(capability.OFSDelta) +} + func (r *Remote) newReferenceUpdateRequest( o *PushOptions, localRefs []*plumbing.Reference, @@ -994,6 +998,7 @@ func pushHashes( s storage.Storer, req *packp.ReferenceUpdateRequest, hs []plumbing.Hash, + useRefDeltas bool, ) (*packp.ReportStatus, error) { rd, wr := io.Pipe() @@ -1004,7 +1009,7 @@ func pushHashes( } done := make(chan error) go func() { - e := packfile.NewEncoder(wr, s, false) + e := packfile.NewEncoder(wr, s, useRefDeltas) if _, err := e.Encode(hs, config.Pack.Window); err != nil { done <- wr.CloseWithError(err) return |