aboutsummaryrefslogtreecommitdiffstats
path: root/plumbing/protocol/packp/srvresp.go
diff options
context:
space:
mode:
Diffstat (limited to 'plumbing/protocol/packp/srvresp.go')
-rw-r--r--plumbing/protocol/packp/srvresp.go14
1 files changed, 14 insertions, 0 deletions
diff --git a/plumbing/protocol/packp/srvresp.go b/plumbing/protocol/packp/srvresp.go
index 3284fa2..d41b50d 100644
--- a/plumbing/protocol/packp/srvresp.go
+++ b/plumbing/protocol/packp/srvresp.go
@@ -68,3 +68,17 @@ func (r *ServerResponse) decodeACKLine(line []byte) error {
r.ACKs = append(r.ACKs, h)
return nil
}
+
+// Encode encodes the ServerResponse into a writer.
+func (r *ServerResponse) Encode(w io.Writer) error {
+ if len(r.ACKs) > 1 {
+ return errors.New("multi_ack and multi_ack_detailed are not supported")
+ }
+
+ e := pktline.NewEncoder(w)
+ if len(r.ACKs) == 0 {
+ return e.Encodef("%s\n", nak)
+ }
+
+ return e.Encodef("%s %s\n", ack, r.ACKs[0].String())
+}