aboutsummaryrefslogtreecommitdiffstats
path: root/plumbing/transport/http
diff options
context:
space:
mode:
authorSantiago M. Mola <santi@mola.io>2016-12-08 14:24:25 +0100
committerGitHub <noreply@github.com>2016-12-08 14:24:25 +0100
commit7d9d9bfee34ea428a127da0df900d3a26de37c38 (patch)
tree225c5661c6be1a000c2e5cc15961c214040c7cff /plumbing/transport/http
parent3962b8d4dbb2d2d61e9282d73f8d3d0f2a222461 (diff)
downloadgo-git-7d9d9bfee34ea428a127da0df900d3a26de37c38.tar.gz
plumbing/transport: allow AdvertisedReferences being called multiple times. (#165)
* AdvertisedReferences is now part of transport.Session. * It is allowed to be called more than once. * It is allowed to be called before and after FetchPack/SendPack. * Implementations cache its result.
Diffstat (limited to 'plumbing/transport/http')
-rw-r--r--plumbing/transport/http/common.go2
-rw-r--r--plumbing/transport/http/fetch_pack.go8
2 files changed, 5 insertions, 5 deletions
diff --git a/plumbing/transport/http/common.go b/plumbing/transport/http/common.go
index a1b085b..aa3425e 100644
--- a/plumbing/transport/http/common.go
+++ b/plumbing/transport/http/common.go
@@ -6,6 +6,7 @@ import (
"net/http"
"gopkg.in/src-d/go-git.v4/plumbing"
+ "gopkg.in/src-d/go-git.v4/plumbing/protocol/packp"
"gopkg.in/src-d/go-git.v4/plumbing/transport"
)
@@ -50,6 +51,7 @@ type session struct {
auth AuthMethod
client *http.Client
endpoint transport.Endpoint
+ advRefs *packp.AdvRefs
}
func (s *session) SetAuth(auth transport.AuthMethod) error {
diff --git a/plumbing/transport/http/fetch_pack.go b/plumbing/transport/http/fetch_pack.go
index 1548110..0c85be4 100644
--- a/plumbing/transport/http/fetch_pack.go
+++ b/plumbing/transport/http/fetch_pack.go
@@ -17,7 +17,6 @@ import (
type fetchPackSession struct {
*session
- advRefsRun bool
}
func newFetchPackSession(c *http.Client,
@@ -33,12 +32,10 @@ func newFetchPackSession(c *http.Client,
}
func (s *fetchPackSession) AdvertisedReferences() (*packp.AdvRefs, error) {
- if s.advRefsRun {
- return nil, transport.ErrAdvertistedReferencesAlreadyCalled
+ if s.advRefs != nil {
+ return s.advRefs, nil
}
- defer func() { s.advRefsRun = true }()
-
url := fmt.Sprintf(
"%s/info/refs?service=%s",
s.endpoint.String(), transport.UploadPackServiceName,
@@ -72,6 +69,7 @@ func (s *fetchPackSession) AdvertisedReferences() (*packp.AdvRefs, error) {
}
transport.FilterUnsupportedCapabilities(ar.Capabilities)
+ s.advRefs = ar
return ar, nil
}