Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Advertise multi ack capabilities #200

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 11 additions & 0 deletions plumbing/format/packfile/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,7 @@ func (p *Parser) resolveDeltas() error {
if err := p.resolveObject(stdioutil.Discard, child, content); err != nil {
return err
}
p.resolveExternalRef(child)
}

// Remove the delta from the cache.
Expand All @@ -299,6 +300,16 @@ func (p *Parser) resolveDeltas() error {
return nil
}

func (p *Parser) resolveExternalRef(o *objectInfo) {
if ref, ok := p.oiByHash[o.SHA1]; ok && ref.ExternalRef {
p.oiByHash[o.SHA1] = o
o.Children = ref.Children
for _, c := range o.Children {
c.Parent = o
}
}
}

func (p *Parser) get(o *objectInfo, buf *bytes.Buffer) (err error) {
if !o.ExternalRef { // skip cache check for placeholder parents
b, ok := p.cache.Get(o.Offset)
Expand Down
5 changes: 0 additions & 5 deletions plumbing/protocol/packp/srvresp.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,6 @@ type ServerResponse struct {
// Decode decodes the response into the struct, isMultiACK should be true, if
// the request was done with multi_ack or multi_ack_detailed capabilities.
func (r *ServerResponse) Decode(reader *bufio.Reader, isMultiACK bool) error {
// TODO: implement support for multi_ack or multi_ack_detailed responses
if isMultiACK {
return errors.New("multi_ack and multi_ack_detailed are not supported")
}

s := pktline.NewScanner(reader)

for s.Scan() {
Expand Down
2 changes: 1 addition & 1 deletion plumbing/protocol/packp/srvresp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,5 +75,5 @@ func (s *ServerResponseSuite) TestDecodeMalformed(c *C) {
func (s *ServerResponseSuite) TestDecodeMultiACK(c *C) {
sr := &ServerResponse{}
err := sr.Decode(bufio.NewReader(bytes.NewBuffer(nil)), true)
c.Assert(err, NotNil)
c.Assert(err, IsNil)
}
4 changes: 3 additions & 1 deletion plumbing/protocol/packp/uppackresp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package packp

import (
"bytes"
"fmt"
"io/ioutil"

"github.com/go-git/go-git/v5/plumbing"
Expand Down Expand Up @@ -67,7 +68,8 @@ func (s *UploadPackResponseSuite) TestDecodeMultiACK(c *C) {
defer res.Close()

err := res.Decode(ioutil.NopCloser(bytes.NewBuffer(nil)))
c.Assert(err, NotNil)
fmt.Println(err)
c.Assert(err, IsNil)
}

func (s *UploadPackResponseSuite) TestReadNoDecode(c *C) {
Expand Down
1 change: 0 additions & 1 deletion plumbing/transport/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,6 @@ func parseFile(endpoint string) (*Endpoint, bool) {
// UnsupportedCapabilities are the capabilities not supported by any client
// implementation
var UnsupportedCapabilities = []capability.Capability{
capability.MultiACK,
capability.MultiACKDetailed,
capability.ThinPack,
}
Expand Down
4 changes: 2 additions & 2 deletions plumbing/transport/common_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -181,8 +181,8 @@ func (s *SuiteCommon) TestNewEndpointInvalidURL(c *C) {

func (s *SuiteCommon) TestFilterUnsupportedCapabilities(c *C) {
l := capability.NewList()
l.Set(capability.MultiACK)
l.Set(capability.MultiACKDetailed)

FilterUnsupportedCapabilities(l)
c.Assert(l.Supports(capability.MultiACK), Equals, false)
c.Assert(l.Supports(capability.MultiACKDetailed), Equals, false)
}
13 changes: 11 additions & 2 deletions plumbing/transport/ssh/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,18 @@ func (c *command) Close() error {

//XXX: If did read the full packfile, then the session might be already
// closed.
_ = c.Session.Close()
serr := c.Session.Close()

// Ignore errors when closing the client if the session has
// already been closed by the server. This has to be done
// as some git server will close the connection before the
// client does.
err := c.client.Close()
if serr != nil && serr.Error() == "EOF" {
return nil
}

return c.client.Close()
return err
}

// connect connects to the SSH server, unless a AuthMethod was set with
Expand Down
2 changes: 1 addition & 1 deletion plumbing/transport/test/upload_pack.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ func (s *UploadPackSuite) TestAdvertisedReferencesFilterUnsupported(c *C) {

info, err := r.AdvertisedReferences()
c.Assert(err, IsNil)
c.Assert(info.Capabilities.Supports(capability.MultiACK), Equals, false)
c.Assert(info.Capabilities.Supports(capability.MultiACKDetailed), Equals, false)
}

func (s *UploadPackSuite) TestCapabilities(c *C) {
Expand Down