From 1d6b13537129018bc7e866ea42ec835e565c6469 Mon Sep 17 00:00:00 2001 From: Máximo Cuadros Date: Thu, 5 Nov 2015 01:48:07 +0100 Subject: clients: capabilities improvement and info head --- clients/common/common.go | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) (limited to 'clients/common/common.go') diff --git a/clients/common/common.go b/clients/common/common.go index 9abb8eb..44d8e6a 100644 --- a/clients/common/common.go +++ b/clients/common/common.go @@ -132,13 +132,24 @@ func (c *Capabilities) String() string { var o string for _, key := range c.o { cap := c.m[key] - if len(cap.Values) == 0 { - o += key + " " - } + added := false for _, value := range cap.Values { + if value == "" { + continue + } + + added = true o += fmt.Sprintf("%s=%s ", key, value) } + + if len(cap.Values) == 0 || !added { + o += key + " " + } + } + + if len(o) == 0 { + return o } return o[:len(o)-1] @@ -180,7 +191,7 @@ func (r *GitUploadPackInfo) read(d *pktline.Decoder) error { } if len(r.Capabilities.o) == 0 { - r.Capabilities.Decode(line) + r.decodeHeaderLine(line) continue } @@ -195,6 +206,13 @@ func (r *GitUploadPackInfo) read(d *pktline.Decoder) error { return nil } +func (r *GitUploadPackInfo) decodeHeaderLine(line string) { + parts := strings.SplitN(line, " HEAD", 2) + + r.Head = parts[0] + r.Capabilities.Decode(line) +} + func (r *GitUploadPackInfo) isValidLine(line string) bool { if line[0] == '#' { return false -- cgit