diff options
author | Máximo Cuadros <mcuadros@gmail.com> | 2015-10-30 11:07:26 +0100 |
---|---|---|
committer | Máximo Cuadros <mcuadros@gmail.com> | 2015-10-30 11:07:26 +0100 |
commit | fcbb68e3658a7929fe4f7e306fa8e9b602ff48f3 (patch) | |
tree | 01bbdabbe3cf0a00d86b1d0c44b92dffcb389ad3 /clients/common/common.go | |
parent | 419ea1639230c5a7613962cbcbe0eb8b9e1ad078 (diff) | |
download | go-git-fcbb68e3658a7929fe4f7e306fa8e9b602ff48f3.tar.gz |
client: handly empty repositories
Diffstat (limited to 'clients/common/common.go')
-rw-r--r-- | clients/common/common.go | 13 |
1 files changed, 12 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 |