aboutsummaryrefslogtreecommitdiffstats
path: root/plumbing
diff options
context:
space:
mode:
Diffstat (limited to 'plumbing')
-rw-r--r--plumbing/protocol/packp/capability/list.go5
-rw-r--r--plumbing/protocol/packp/capability/list_test.go9
2 files changed, 14 insertions, 0 deletions
diff --git a/plumbing/protocol/packp/capability/list.go b/plumbing/protocol/packp/capability/list.go
index 7197d36..2847580 100644
--- a/plumbing/protocol/packp/capability/list.go
+++ b/plumbing/protocol/packp/capability/list.go
@@ -48,6 +48,11 @@ func (l *List) IsEmpty() bool {
// Decode decodes list of capabilities from raw into the list
func (l *List) Decode(raw []byte) error {
+ // git 1.x receive pack used to send a leading space on its
+ // git-receive-pack capabilities announcement. We just trim space to be
+ // tolerant to space changes in different versions.
+ raw = bytes.TrimSpace(raw)
+
if len(raw) == 0 {
return nil
}
diff --git a/plumbing/protocol/packp/capability/list_test.go b/plumbing/protocol/packp/capability/list_test.go
index d6aac16..42f0179 100644
--- a/plumbing/protocol/packp/capability/list_test.go
+++ b/plumbing/protocol/packp/capability/list_test.go
@@ -27,6 +27,15 @@ func (s *SuiteCapabilities) TestDecode(c *check.C) {
c.Assert(cap.Get(ThinPack), check.IsNil)
}
+func (s *SuiteCapabilities) TestDecodeWithLeadingSpace(c *check.C) {
+ cap := NewList()
+ err := cap.Decode([]byte(" report-status"))
+ c.Assert(err, check.IsNil)
+
+ c.Assert(cap.m, check.HasLen, 1)
+ c.Assert(cap.Supports(ReportStatus), check.Equals, true)
+}
+
func (s *SuiteCapabilities) TestDecodeEmpty(c *check.C) {
cap := NewList()
err := cap.Decode(nil)