diff options
author | Santiago M. Mola <santi@mola.io> | 2016-12-09 14:44:03 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-12-09 14:44:03 +0100 |
commit | 0e1a52757a3938e97cf7d31e0dff3c9949001763 (patch) | |
tree | 8b998fdc3eaaf6b2d6c69a125759a778664207a5 /plumbing/protocol/packp/report_status.go | |
parent | 4f16cc925238aae81586e917d26b8ff6b6a340bd (diff) | |
download | go-git-0e1a52757a3938e97cf7d31e0dff3c9949001763.tar.gz |
transport: add git-send-pack support to local/ssh. (#163)
* protocol/packp: add Packfile field to ReferenceUpdateRequest.
* protocol/packp: add NewReferenceUpdateRequestFromCapabilities.
* NewReferenceUpdateRequestFromCapabilities can be used to create
a ReferenceUpdateRequest with initial capabilities compatible with
the server.
* protocol/packp: fix new line handling on report status.
* transport/file: test error on unexisting command.
Diffstat (limited to 'plumbing/protocol/packp/report_status.go')
-rw-r--r-- | plumbing/protocol/packp/report_status.go | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/plumbing/protocol/packp/report_status.go b/plumbing/protocol/packp/report_status.go index f480b34..ead4bb6 100644 --- a/plumbing/protocol/packp/report_status.go +++ b/plumbing/protocol/packp/report_status.go @@ -1,12 +1,13 @@ package packp import ( + "bytes" + "fmt" "io" + "strings" - "fmt" "gopkg.in/src-d/go-git.v4/plumbing" "gopkg.in/src-d/go-git.v4/plumbing/format/pktline" - "strings" ) const ( @@ -33,7 +34,7 @@ func (s *ReportStatus) Ok() bool { // Encode writes the report status to a writer. func (s *ReportStatus) Encode(w io.Writer) error { e := pktline.NewEncoder(w) - if err := e.Encodef("unpack %s", s.UnpackStatus); err != nil { + if err := e.Encodef("unpack %s\n", s.UnpackStatus); err != nil { return err } @@ -95,6 +96,8 @@ func (s *ReportStatus) decodeReportStatus(b []byte) error { return fmt.Errorf("premature flush") } + b = bytes.TrimSuffix(b, eol) + line := string(b) fields := strings.SplitN(line, " ", 2) if len(fields) != 2 || fields[0] != "unpack" { @@ -106,6 +109,8 @@ func (s *ReportStatus) decodeReportStatus(b []byte) error { } func (s *ReportStatus) decodeCommandStatus(b []byte) error { + b = bytes.TrimSuffix(b, eol) + line := string(b) fields := strings.SplitN(line, " ", 3) status := ok @@ -138,8 +143,8 @@ func (s *CommandStatus) Ok() bool { func (s *CommandStatus) encode(w io.Writer) error { e := pktline.NewEncoder(w) if s.Ok() { - return e.Encodef("ok %s", s.ReferenceName.String()) + return e.Encodef("ok %s\n", s.ReferenceName.String()) } - return e.Encodef("ng %s %s", s.ReferenceName.String(), s.Status) + return e.Encodef("ng %s %s\n", s.ReferenceName.String(), s.Status) } |