aboutsummaryrefslogtreecommitdiffstats
path: root/remote.go
diff options
context:
space:
mode:
authorBenjamin Ash <bash@intelerad.com>2018-10-16 15:57:12 -0400
committerBenjamin Ash <bash@intelerad.com>2018-10-16 16:16:53 -0400
commit1618e1cf321aa9cee6d0c11cb14e265b049563c4 (patch)
tree89c48506ad42b4e0baea2345cdc77d7563620ec0 /remote.go
parentcd64b4d630b6c2d2b3d72e9615e14f9d58bb5787 (diff)
downloadgo-git-1618e1cf321aa9cee6d0c11cb14e265b049563c4.tar.gz
remote: use reference deltas on push when the remote server does not
support offset deltas Signed-off-by: Benjamin Ash <bash@intelerad.com>
Diffstat (limited to 'remote.go')
-rw-r--r--remote.go9
1 files changed, 7 insertions, 2 deletions
diff --git a/remote.go b/remote.go
index 0556b98..8f4e41d 100644
--- a/remote.go
+++ b/remote.go
@@ -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