From c2958bf730224cc3672e2105faa1879ec5f21cee Mon Sep 17 00:00:00 2001 From: ThinkChaos Date: Fri, 17 Feb 2023 16:15:22 -0500 Subject: fix: don't use the `firstErrLine` when it is empty Returning `nil` causes `handleAdvRefDecodeError` to fall back to `io.ErrUnexpectedEOF`. --- plumbing/transport/internal/common/common.go | 2 +- plumbing/transport/internal/common/common_test.go | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) (limited to 'plumbing/transport/internal/common') diff --git a/plumbing/transport/internal/common/common.go b/plumbing/transport/internal/common/common.go index d0e9a29..b2c2fee 100644 --- a/plumbing/transport/internal/common/common.go +++ b/plumbing/transport/internal/common/common.go @@ -374,7 +374,7 @@ func (s *session) checkNotFoundError() error { case <-t.C: return ErrTimeoutExceeded case line, ok := <-s.firstErrLine: - if !ok { + if !ok || len(line) == 0 { return nil } diff --git a/plumbing/transport/internal/common/common_test.go b/plumbing/transport/internal/common/common_test.go index c60ef3b..affa787 100644 --- a/plumbing/transport/internal/common/common_test.go +++ b/plumbing/transport/internal/common/common_test.go @@ -76,3 +76,17 @@ func (s *CommonSuite) TestIsRepoNotFoundErrorForGogsAccessDenied(c *C) { c.Assert(isRepoNotFound, Equals, true) } + +func (s *CommonSuite) TestCheckNotFoundError(c *C) { + firstErrLine := make(chan string, 1) + + session := session{ + firstErrLine: firstErrLine, + } + + firstErrLine <- "" + + err := session.checkNotFoundError() + + c.Assert(err, IsNil) +} -- cgit From 096b3cc16b547f3c0d6e4f92046945bcfac0fa14 Mon Sep 17 00:00:00 2001 From: Paulo Gomes Date: Thu, 11 May 2023 21:59:37 +0100 Subject: *: Remove use of deprecated io/util Signed-off-by: Paulo Gomes --- plumbing/transport/internal/common/common.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'plumbing/transport/internal/common') diff --git a/plumbing/transport/internal/common/common.go b/plumbing/transport/internal/common/common.go index b2c2fee..99e0850 100644 --- a/plumbing/transport/internal/common/common.go +++ b/plumbing/transport/internal/common/common.go @@ -11,7 +11,6 @@ import ( "errors" "fmt" "io" - stdioutil "io/ioutil" "strings" "time" @@ -156,7 +155,7 @@ func (c *client) listenFirstError(r io.Reader) chan string { close(errLine) } - _, _ = io.Copy(stdioutil.Discard, r) + _, _ = io.Copy(io.Discard, r) }() return errLine -- cgit From 025e1311f8473f65facf8cffeccc11e39466db4a Mon Sep 17 00:00:00 2001 From: Arieh Schneier <15041913+AriehSchneier@users.noreply.github.com> Date: Sun, 2 Jul 2023 22:51:41 +1000 Subject: plumbing: packp, A request is not empty if it contains shallows. Fixes #328 Signed-off-by: Arieh Schneier <15041913+AriehSchneier@users.noreply.github.com> --- plumbing/transport/internal/common/common.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'plumbing/transport/internal/common') diff --git a/plumbing/transport/internal/common/common.go b/plumbing/transport/internal/common/common.go index 99e0850..5fdf425 100644 --- a/plumbing/transport/internal/common/common.go +++ b/plumbing/transport/internal/common/common.go @@ -232,7 +232,7 @@ func (s *session) handleAdvRefDecodeError(err error) error { // UploadPack performs a request to the server to fetch a packfile. A reader is // returned with the packfile content. The reader must be closed after reading. func (s *session) UploadPack(ctx context.Context, req *packp.UploadPackRequest) (*packp.UploadPackResponse, error) { - if req.IsEmpty() && len(req.Shallows) == 0 { + if req.IsEmpty() { return nil, transport.ErrEmptyUploadPackRequest } -- cgit