aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThinkChaos <ThinkChaos@users.noreply.github.com>2023-02-17 16:15:22 -0500
committerThinkChaos <ThinkChaos@users.noreply.github.com>2023-02-21 19:05:12 -0500
commitc2958bf730224cc3672e2105faa1879ec5f21cee (patch)
tree4b6cb8f617301e7cfa9235c64261c5cf666d4009
parent7ab4957732a817bada223e5c361f0c9753d9e40c (diff)
downloadgo-git-c2958bf730224cc3672e2105faa1879ec5f21cee.tar.gz
fix: don't use the `firstErrLine` when it is empty
Returning `nil` causes `handleAdvRefDecodeError` to fall back to `io.ErrUnexpectedEOF`.
-rw-r--r--plumbing/transport/internal/common/common.go2
-rw-r--r--plumbing/transport/internal/common/common_test.go14
2 files changed, 15 insertions, 1 deletions
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)
+}