From 39853aab188cb0b7e7c31c99b82149684df9a33c Mon Sep 17 00:00:00 2001 From: Jeremy Stribling Date: Mon, 2 Oct 2017 14:31:37 -0700 Subject: remote: add the last 100 commits for each ref in haves list If the local ref is not an ancestor of the remote ref being fetched, then when we send an UploadPack request with that local ref as one of the Haves, the remote will not recognize it, and will think we are asking for the entire history of the repo, even if there's a common ancestor. To do this right, we need to support the multi-ack protocol so we can negotiate a common commit. That's hard though; this is a quick fix just to include the previous 100 commits for each local ref in the Haves list, and hope that one of them is the common commit. --- remote_test.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'remote_test.go') diff --git a/remote_test.go b/remote_test.go index 2b8680d..a38675a 100644 --- a/remote_test.go +++ b/remote_test.go @@ -625,6 +625,10 @@ func (s *RemoteSuite) TestPushWrongRemoteName(c *C) { } func (s *RemoteSuite) TestGetHaves(c *C) { + f := fixtures.Basic().One() + sto, err := filesystem.NewStorage(f.DotGit()) + c.Assert(err, IsNil) + var localRefs = []*plumbing.Reference{ plumbing.NewReferenceFromStrings( "foo", @@ -640,7 +644,7 @@ func (s *RemoteSuite) TestGetHaves(c *C) { ), } - l, err := getHaves(localRefs) + l, err := getHaves(localRefs, memory.NewStorage(), sto) c.Assert(err, IsNil) c.Assert(l, HasLen, 2) } -- cgit