aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--clients/common/common.go13
-rw-r--r--clients/common/common_test.go6
2 files changed, 18 insertions, 1 deletions
diff --git a/clients/common/common.go b/clients/common/common.go
index d29706d..0140847 100644
--- a/clients/common/common.go
+++ b/clients/common/common.go
@@ -14,7 +14,8 @@ import (
)
var (
- NotFoundErr = errors.New("repository not found")
+ NotFoundErr = errors.New("repository not found")
+ EmptyGitUploadPackErr = errors.New("empty git-upload-pack given")
)
const GitUploadPackServiceName = "git-upload-pack"
@@ -93,6 +94,10 @@ type GitUploadPackInfo struct {
func NewGitUploadPackInfo(d *pktline.Decoder) (*GitUploadPackInfo, error) {
info := &GitUploadPackInfo{}
if err := info.read(d); err != nil {
+ if err == EmptyGitUploadPackErr {
+ return nil, NewPermanentError(err)
+ }
+
return nil, NewUnexpectedError(err)
}
@@ -105,6 +110,7 @@ func (r *GitUploadPackInfo) read(d *pktline.Decoder) error {
return err
}
+ isEmpty := true
r.Refs = map[string]*RemoteHead{}
for _, line := range lines {
if !r.isValidLine(line) {
@@ -117,6 +123,11 @@ func (r *GitUploadPackInfo) read(d *pktline.Decoder) error {
}
r.readLine(line)
+ isEmpty = false
+ }
+
+ if isEmpty {
+ return EmptyGitUploadPackErr
}
return nil
diff --git a/clients/common/common_test.go b/clients/common/common_test.go
index 43faf5b..b397ac9 100644
--- a/clients/common/common_test.go
+++ b/clients/common/common_test.go
@@ -53,6 +53,12 @@ func (s *SuiteCommon) TestGitUploadPackInfo(c *C) {
c.Assert(info.Refs[ref].Name, Equals, "refs/heads/master")
}
+func (s *SuiteCommon) TestGitUploadPackInfoEmpty(c *C) {
+ b := bytes.NewBuffer(nil)
+ _, err := NewGitUploadPackInfo(pktline.NewDecoder(b))
+ c.Assert(err, ErrorMatches, "permanent.*empty.*")
+}
+
func (s *SuiteCommon) TestGitUploadPackRequest(c *C) {
r := &GitUploadPackRequest{
Want: []internal.Hash{