aboutsummaryrefslogtreecommitdiffstats
path: root/plumbing
diff options
context:
space:
mode:
authorAyman Bagabas <ayman.bagabas@gmail.com>2023-11-16 11:28:02 -0500
committerAyman Bagabas <ayman.bagabas@gmail.com>2023-11-16 14:00:38 -0500
commit05551b70f689944ab558a2b326b2174f313d372a (patch)
treed89c591da2d37b99b2cd0f6e9ea6f67a91c9ee11 /plumbing
parent63b586b9559508baf7442c39db3327c91d37486c (diff)
downloadgo-git-05551b70f689944ab558a2b326b2174f313d372a.tar.gz
plumbing: fix empty uploadpack request error
If we have all what we asked for, finish the session and handle error. This is equivalent of git "Already up to date." message. Fixes: https://github.com/go-git/go-git/issues/328 Fixes: https://github.com/go-git/go-git/issues/638 Fixes: https://github.com/go-git/go-git/issues/157
Diffstat (limited to 'plumbing')
-rw-r--r--plumbing/transport/internal/common/common.go6
1 files changed, 6 insertions, 0 deletions
diff --git a/plumbing/transport/internal/common/common.go b/plumbing/transport/internal/common/common.go
index 6574116..da1c2ac 100644
--- a/plumbing/transport/internal/common/common.go
+++ b/plumbing/transport/internal/common/common.go
@@ -245,6 +245,12 @@ func (s *session) handleAdvRefDecodeError(err error) error {
// 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() {
+ // XXX: IsEmpty means haves are a subset of wants, in that case we have
+ // everything we asked for. Close the connection and return nil.
+ if err := s.finish(); err != nil {
+ return nil, err
+ }
+ // TODO:(v6) return nil here
return nil, transport.ErrEmptyUploadPackRequest
}