aboutsummaryrefslogtreecommitdiffstats
path: root/plumbing/protocol/packp/uppackreq.go
diff options
context:
space:
mode:
authorAntonio Navarro Perez <antnavper@gmail.com>2017-01-25 00:30:09 +0100
committerMáximo Cuadros <mcuadros@gmail.com>2017-01-25 00:30:09 +0100
commitdc45de29f87a43078356a5be4c4b5aa24f626ee0 (patch)
treea36e94fedc5d82155c67857f8e8a8632fb15ff1e /plumbing/protocol/packp/uppackreq.go
parente549c1819773fd8ab302ecd1b7650c25aafaba43 (diff)
downloadgo-git-dc45de29f87a43078356a5be4c4b5aa24f626ee0.tar.gz
transport/http: fix partial request with haves. Fix #216. (#221)
Diffstat (limited to 'plumbing/protocol/packp/uppackreq.go')
-rw-r--r--plumbing/protocol/packp/uppackreq.go7
1 files changed, 4 insertions, 3 deletions
diff --git a/plumbing/protocol/packp/uppackreq.go b/plumbing/protocol/packp/uppackreq.go
index 84e2b4e..4bb22d0 100644
--- a/plumbing/protocol/packp/uppackreq.go
+++ b/plumbing/protocol/packp/uppackreq.go
@@ -68,8 +68,9 @@ type UploadHaves struct {
Haves []plumbing.Hash
}
-// Encode encodes the UploadHaves into the Writer.
-func (u *UploadHaves) Encode(w io.Writer) error {
+// Encode encodes the UploadHaves into the Writer. If flush is true, a flush
+// command will be encoded at the end of the writer content.
+func (u *UploadHaves) Encode(w io.Writer, flush bool) error {
e := pktline.NewEncoder(w)
plumbing.HashesSort(u.Haves)
@@ -87,7 +88,7 @@ func (u *UploadHaves) Encode(w io.Writer) error {
last = have
}
- if len(u.Haves) != 0 {
+ if flush && len(u.Haves) != 0 {
if err := e.Flush(); err != nil {
return fmt.Errorf("sending flush-pkt after haves: %s", err)
}