diff options
-rw-r--r-- | plumbing/transport/file/client.go | 3 | ||||
-rw-r--r-- | plumbing/transport/server/server.go | 2 | ||||
-rw-r--r-- | remote.go | 2 | ||||
-rw-r--r-- | utils/ioutil/common.go | 12 | ||||
-rw-r--r-- | utils/ioutil/pipe.go | 9 | ||||
-rw-r--r-- | utils/ioutil/pipe_js.go | 9 |
6 files changed, 33 insertions, 4 deletions
diff --git a/plumbing/transport/file/client.go b/plumbing/transport/file/client.go index 38714e2..6f0a380 100644 --- a/plumbing/transport/file/client.go +++ b/plumbing/transport/file/client.go @@ -11,6 +11,7 @@ import ( "github.com/go-git/go-git/v5/plumbing/transport" "github.com/go-git/go-git/v5/plumbing/transport/internal/common" + "github.com/go-git/go-git/v5/utils/ioutil" "golang.org/x/sys/execabs" ) @@ -111,7 +112,7 @@ func (c *command) Start() error { func (c *command) StderrPipe() (io.Reader, error) { // Pipe returned by Command.StderrPipe has a race with Read + Command.Wait. // We use an io.Pipe and close it after the command finishes. - r, w := io.Pipe() + r, w := ioutil.Pipe() c.cmd.Stderr = w c.stderrCloser = r return r, nil diff --git a/plumbing/transport/server/server.go b/plumbing/transport/server/server.go index 6f89ec3..8ab70fe 100644 --- a/plumbing/transport/server/server.go +++ b/plumbing/transport/server/server.go @@ -166,7 +166,7 @@ func (s *upSession) UploadPack(ctx context.Context, req *packp.UploadPackRequest return nil, err } - pr, pw := io.Pipe() + pr, pw := ioutil.Pipe() e := packfile.NewEncoder(pw, s.storer, false) go func() { // TODO: plumb through a pack window. @@ -1125,7 +1125,7 @@ func pushHashes( allDelete bool, ) (*packp.ReportStatus, error) { - rd, wr := io.Pipe() + rd, wr := ioutil.Pipe() config, err := s.Config() if err != nil { diff --git a/utils/ioutil/common.go b/utils/ioutil/common.go index e9dcbfe..b52e85a 100644 --- a/utils/ioutil/common.go +++ b/utils/ioutil/common.go @@ -7,7 +7,7 @@ import ( "errors" "io" - "github.com/jbenet/go-context/io" + ctxio "github.com/jbenet/go-context/io" ) type readPeeker interface { @@ -168,3 +168,13 @@ func (r *writerOnError) Write(p []byte) (n int, err error) { return } + +type PipeReader interface { + io.ReadCloser + CloseWithError(err error) error +} + +type PipeWriter interface { + io.WriteCloser + CloseWithError(err error) error +} diff --git a/utils/ioutil/pipe.go b/utils/ioutil/pipe.go new file mode 100644 index 0000000..f30c452 --- /dev/null +++ b/utils/ioutil/pipe.go @@ -0,0 +1,9 @@ +// +build !js + +package ioutil + +import "io" + +func Pipe() (PipeReader, PipeWriter) { + return io.Pipe() +} diff --git a/utils/ioutil/pipe_js.go b/utils/ioutil/pipe_js.go new file mode 100644 index 0000000..cf102e6 --- /dev/null +++ b/utils/ioutil/pipe_js.go @@ -0,0 +1,9 @@ +// +build js + +package ioutil + +import "github.com/acomagu/bufpipe" + +func Pipe() (PipeReader, PipeWriter) { + return bufpipe.New(nil) +} |