diff options
Diffstat (limited to 'plumbing/protocol/packp/capability')
-rw-r--r-- | plumbing/protocol/packp/capability/list.go | 4 | ||||
-rw-r--r-- | plumbing/protocol/packp/capability/list_test.go | 7 |
2 files changed, 11 insertions, 0 deletions
diff --git a/plumbing/protocol/packp/capability/list.go b/plumbing/protocol/packp/capability/list.go index 73d1f25..ff8d4a4 100644 --- a/plumbing/protocol/packp/capability/list.go +++ b/plumbing/protocol/packp/capability/list.go @@ -48,6 +48,10 @@ func (l *List) IsEmpty() bool { // Decode decodes list of capabilities from raw into the list func (l *List) Decode(raw []byte) error { + if len(raw) == 0 { + return nil + } + for _, data := range bytes.Split(raw, []byte{' '}) { pair := bytes.SplitN(data, []byte{'='}, 2) diff --git a/plumbing/protocol/packp/capability/list_test.go b/plumbing/protocol/packp/capability/list_test.go index 6d350b0..eeb3173 100644 --- a/plumbing/protocol/packp/capability/list_test.go +++ b/plumbing/protocol/packp/capability/list_test.go @@ -27,6 +27,13 @@ func (s *SuiteCapabilities) TestDecode(c *check.C) { c.Assert(cap.Get(ThinPack), check.IsNil) } +func (s *SuiteCapabilities) TestDecodeEmpty(c *check.C) { + cap := NewList() + err := cap.Decode(nil) + c.Assert(err, check.IsNil) + c.Assert(cap, check.DeepEquals, NewList()) +} + func (s *SuiteCapabilities) TestDecodeWithErrArguments(c *check.C) { cap := NewList() err := cap.Decode([]byte("thin-pack=foo")) |