aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMáximo Cuadros <mcuadros@gmail.com>2017-06-24 00:31:20 -0700
committerGitHub <noreply@github.com>2017-06-24 00:31:20 -0700
commit2d02297a9156390d1a23584bd9d9833c65998f40 (patch)
treeab19084771f47dd527ab3b7a6d4d11b872b983af
parent7e733657d9cd931459825abf4fe71f31f0707313 (diff)
parentcb55d396c8fdeae4975592e7bc973c354f73bd63 (diff)
downloadgo-git-2d02297a9156390d1a23584bd9d9833c65998f40.tar.gz
Merge pull request #451 from smola/hotfix-unknown-capabilities
capability: accept unknown capabilities, fixes #450
-rw-r--r--plumbing/protocol/packp/capability/list.go6
-rw-r--r--plumbing/protocol/packp/capability/list_test.go10
2 files changed, 6 insertions, 10 deletions
diff --git a/plumbing/protocol/packp/capability/list.go b/plumbing/protocol/packp/capability/list.go
index 69fdb51..3904a4e 100644
--- a/plumbing/protocol/packp/capability/list.go
+++ b/plumbing/protocol/packp/capability/list.go
@@ -8,8 +8,6 @@ import (
)
var (
- // ErrUnknownCapability is returned if a unknown capability is given
- ErrUnknownCapability = errors.New("unknown capability")
// ErrArgumentsRequired is returned if no arguments are giving with a
// capability that requires arguments
ErrArgumentsRequired = errors.New("arguments required")
@@ -119,10 +117,6 @@ func (l *List) Add(c Capability, values ...string) error {
}
func (l *List) validate(c Capability, values []string) error {
- if _, ok := valid[c]; !ok {
- return ErrUnknownCapability
- }
-
if requiresArgument[c] && len(values) == 0 {
return ErrArgumentsRequired
}
diff --git a/plumbing/protocol/packp/capability/list_test.go b/plumbing/protocol/packp/capability/list_test.go
index 0a0ad26..9665e89 100644
--- a/plumbing/protocol/packp/capability/list_test.go
+++ b/plumbing/protocol/packp/capability/list_test.go
@@ -58,10 +58,11 @@ func (s *SuiteCapabilities) TestDecodeWithEqual(c *check.C) {
c.Assert(cap.Get(Agent), check.DeepEquals, []string{"foo=bar"})
}
-func (s *SuiteCapabilities) TestDecodeWithErrUnknownCapability(c *check.C) {
+func (s *SuiteCapabilities) TestDecodeWithUnknownCapability(c *check.C) {
cap := NewList()
err := cap.Decode([]byte("foo"))
- c.Assert(err, check.Equals, ErrUnknownCapability)
+ c.Assert(err, check.IsNil)
+ c.Assert(cap.Supports(Capability("foo")), check.Equals, true)
}
func (s *SuiteCapabilities) TestString(c *check.C) {
@@ -133,10 +134,11 @@ func (s *SuiteCapabilities) TestAdd(c *check.C) {
c.Assert(cap.String(), check.Equals, "symref=foo symref=qux thin-pack")
}
-func (s *SuiteCapabilities) TestAddErrUnknownCapability(c *check.C) {
+func (s *SuiteCapabilities) TestAddUnknownCapability(c *check.C) {
cap := NewList()
err := cap.Add(Capability("foo"))
- c.Assert(err, check.Equals, ErrUnknownCapability)
+ c.Assert(err, check.IsNil)
+ c.Assert(cap.Supports(Capability("foo")), check.Equals, true)
}
func (s *SuiteCapabilities) TestAddErrArgumentsRequired(c *check.C) {