From 05551b70f689944ab558a2b326b2174f313d372a Mon Sep 17 00:00:00 2001 From: Ayman Bagabas Date: Thu, 16 Nov 2023 11:28:02 -0500 Subject: 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 --- plumbing/transport/internal/common/common.go | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'plumbing/transport/internal/common') 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 } -- cgit