diff options
author | Máximo Cuadros <mcuadros@gmail.com> | 2015-11-05 01:48:07 +0100 |
---|---|---|
committer | Máximo Cuadros <mcuadros@gmail.com> | 2015-11-05 01:48:07 +0100 |
commit | 1d6b13537129018bc7e866ea42ec835e565c6469 (patch) | |
tree | 5527498133a45fee26e471e4f8be4f35299beedb /clients/common/common.go | |
parent | 6badbeb07eb5cc0b1be201f5d8cc8193e30bcf54 (diff) | |
download | go-git-1d6b13537129018bc7e866ea42ec835e565c6469.tar.gz |
clients: capabilities improvement and info head
Diffstat (limited to 'clients/common/common.go')
-rw-r--r-- | clients/common/common.go | 26 |
1 files changed, 22 insertions, 4 deletions
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 |