From 9d4773cbae0c2ae9b6931c5a6bbac3da8d074ac7 Mon Sep 17 00:00:00 2001 From: Antonio Jesus Navarro Perez Date: Mon, 19 Jun 2017 12:52:03 +0200 Subject: revlist: ignore treeEntries that are submodules. - If we don't ignore submodules in trees, when we tried to perform a push, revlist.Objects returned hashes that was from submodules, causing an "object not found" error in packfile generation. --- plumbing/revlist/revlist.go | 5 +++++ plumbing/revlist/revlist_test.go | 20 +++++++++++++++++++- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/plumbing/revlist/revlist.go b/plumbing/revlist/revlist.go index 3e02184..20bc99d 100644 --- a/plumbing/revlist/revlist.go +++ b/plumbing/revlist/revlist.go @@ -7,6 +7,7 @@ import ( "io" "gopkg.in/src-d/go-git.v4/plumbing" + "gopkg.in/src-d/go-git.v4/plumbing/filemode" "gopkg.in/src-d/go-git.v4/plumbing/object" "gopkg.in/src-d/go-git.v4/plumbing/storer" ) @@ -121,6 +122,10 @@ func iterateCommitTrees( return err } + if e.Mode == filemode.Submodule { + continue + } + if seen[e.Hash] { continue } diff --git a/plumbing/revlist/revlist_test.go b/plumbing/revlist/revlist_test.go index 0baf27e..dd1e8c1 100644 --- a/plumbing/revlist/revlist_test.go +++ b/plumbing/revlist/revlist_test.go @@ -3,12 +3,12 @@ package revlist import ( "testing" - "github.com/src-d/go-git-fixtures" "gopkg.in/src-d/go-git.v4/plumbing" "gopkg.in/src-d/go-git.v4/plumbing/object" "gopkg.in/src-d/go-git.v4/plumbing/storer" "gopkg.in/src-d/go-git.v4/storage/filesystem" + "github.com/src-d/go-git-fixtures" . "gopkg.in/check.v1" ) @@ -62,6 +62,24 @@ func (s *RevListSuite) commit(c *C, h plumbing.Hash) *object.Commit { return commit } +func (s *RevListSuite) TestRevListObjects_Submodules(c *C) { + submodules := map[string]bool{ + "6ecf0ef2c2dffb796033e5a02219af86ec6584e5": true, + } + + sto, err := filesystem.NewStorage(fixtures.ByTag("submodule").One().DotGit()) + c.Assert(err, IsNil) + + ref, err := storer.ResolveReference(sto, plumbing.HEAD) + c.Assert(err, IsNil) + + revList, err := Objects(sto, []plumbing.Hash{ref.Hash()}, nil) + c.Assert(err, IsNil) + for _, h := range revList { + c.Assert(submodules[h.String()], Equals, false) + } +} + // --- // | |\ // | | * b8e471f Creating changelog -- cgit