diff options
author | Javi Fontan <jfontan@gmail.com> | 2018-04-16 19:01:49 +0200 |
---|---|---|
committer | Javi Fontan <jfontan@gmail.com> | 2018-04-16 19:01:49 +0200 |
commit | 75da83739f25f528bf242341d62e01b773329470 (patch) | |
tree | c3fbaf323e0e1a46364f39c97a7721b8f53a7635 /repository_test.go | |
parent | 0db54e829f81a28f71c22d54c03daba5ec144c8d (diff) | |
download | go-git-75da83739f25f528bf242341d62e01b773329470.tar.gz |
git: remote, Add shallow commits instead of substituting. Fixes #412
updateShallow substituted the previous shallow list with the one
returned by the UploadPackResponse. If the repository had previous
shallow commits these are deleted from the list.
This change adds the new shallow hashes to the old ones.
Signed-off-by: Javi Fontan <jfontan@gmail.com>
Diffstat (limited to 'repository_test.go')
-rw-r--r-- | repository_test.go | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/repository_test.go b/repository_test.go index c98e2ac..be7f163 100644 --- a/repository_test.go +++ b/repository_test.go @@ -1615,3 +1615,66 @@ func executeOnPath(path, cmd string) error { return c.Run() } + +func (s *RepositorySuite) TestBrokenMultipleShallowFetch(c *C) { + r, _ := Init(memory.NewStorage(), nil) + _, err := r.CreateRemote(&config.RemoteConfig{ + Name: DefaultRemoteName, + URLs: []string{s.GetBasicLocalRepositoryURL()}, + }) + c.Assert(err, IsNil) + + c.Assert(r.Fetch(&FetchOptions{ + Depth: 2, + RefSpecs: []config.RefSpec{config.RefSpec("refs/heads/master:refs/heads/master")}, + }), IsNil) + + shallows, err := r.Storer.Shallow() + c.Assert(err, IsNil) + c.Assert(len(shallows), Equals, 1) + + ref, err := r.Reference("refs/heads/master", true) + c.Assert(err, IsNil) + cobj, err := r.CommitObject(ref.Hash()) + c.Assert(err, IsNil) + c.Assert(cobj, NotNil) + err = object.NewCommitPreorderIter(cobj, nil, nil).ForEach(func(c *object.Commit) error { + for _, ph := range c.ParentHashes { + for _, h := range shallows { + if ph == h { + return storer.ErrStop + } + } + } + + return nil + }) + c.Assert(err, IsNil) + + c.Assert(r.Fetch(&FetchOptions{ + Depth: 5, + RefSpecs: []config.RefSpec{config.RefSpec("refs/heads/*:refs/heads/*")}, + }), IsNil) + + shallows, err = r.Storer.Shallow() + c.Assert(err, IsNil) + c.Assert(len(shallows), Equals, 3) + + ref, err = r.Reference("refs/heads/master", true) + c.Assert(err, IsNil) + cobj, err = r.CommitObject(ref.Hash()) + c.Assert(err, IsNil) + c.Assert(cobj, NotNil) + err = object.NewCommitPreorderIter(cobj, nil, nil).ForEach(func(c *object.Commit) error { + for _, ph := range c.ParentHashes { + for _, h := range shallows { + if ph == h { + return storer.ErrStop + } + } + } + + return nil + }) + c.Assert(err, IsNil) +} |