diff options
Diffstat (limited to 'plumbing/protocol/packp/uppackreq.go')
-rw-r--r-- | plumbing/protocol/packp/uppackreq.go | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/plumbing/protocol/packp/uppackreq.go b/plumbing/protocol/packp/uppackreq.go index 2b1cb84..887d27a 100644 --- a/plumbing/protocol/packp/uppackreq.go +++ b/plumbing/protocol/packp/uppackreq.go @@ -1,6 +1,7 @@ package packp import ( + "bytes" "fmt" "io" @@ -68,10 +69,20 @@ type UploadHaves struct { // Encode encodes the UploadHaves into the Writer. func (u *UploadHaves) Encode(w io.Writer) error { e := pktline.NewEncoder(w) + + plumbing.HashesSort(u.Haves) + + var last plumbing.Hash for _, have := range u.Haves { + if bytes.Compare(last[:], have[:]) == 0 { + continue + } + if err := e.Encodef("have %s\n", have); err != nil { return fmt.Errorf("sending haves for %q: %s", have, err) } + + last = have } if len(u.Haves) != 0 { |