aboutsummaryrefslogtreecommitdiffstats
path: root/plumbing/object/commitnode_test.go
diff options
context:
space:
mode:
authorFilip Navara <filip.navara@gmail.com>2019-04-24 12:48:30 +0200
committerFilip Navara <filip.navara@gmail.com>2019-04-24 12:48:30 +0200
commitcc48439674365fc8f216dd7df361872046f52f04 (patch)
treeef8f6014afc0fa1b80135948f1c98e88db4f8157 /plumbing/object/commitnode_test.go
parentb48e4867d1aba5235132533006c8ed8be40344d8 (diff)
downloadgo-git-cc48439674365fc8f216dd7df361872046f52f04.tar.gz
Add test for traversal on mixed object and commit-graph
Signed-off-by: Filip Navara <filip.navara@gmail.com>
Diffstat (limited to 'plumbing/object/commitnode_test.go')
-rw-r--r--plumbing/object/commitnode_test.go30
1 files changed, 30 insertions, 0 deletions
diff --git a/plumbing/object/commitnode_test.go b/plumbing/object/commitnode_test.go
index 1e5f2d9..df307e3 100644
--- a/plumbing/object/commitnode_test.go
+++ b/plumbing/object/commitnode_test.go
@@ -102,3 +102,33 @@ func (s *CommitNodeSuite) TestCommitGraph(c *C) {
testWalker(c, nodeIndex)
testParents(c, nodeIndex)
}
+
+func (s *CommitNodeSuite) TestMixedGraph(c *C) {
+ // Unpack the original repository with pack file
+ f := fixtures.ByTag("commit-graph").One()
+ dotgit := f.DotGit()
+ storer := filesystem.NewStorage(dotgit, cache.NewObjectLRUDefault())
+ p := f.Packfile()
+ defer p.Close()
+ err := packfile.UpdateObjectStorage(storer, p)
+ c.Assert(err, IsNil)
+
+ // Take the commit-graph file and copy it to memory index without the last commit
+ reader, err := mmap.Open(path.Join(dotgit.Root(), "objects", "info", "commit-graph"))
+ c.Assert(err, IsNil)
+ defer reader.Close()
+ fileIndex, err := commitgraph.OpenFileIndex(reader)
+ c.Assert(err, IsNil)
+ memoryIndex := commitgraph.NewMemoryIndex()
+ for i, hash := range fileIndex.Hashes() {
+ if hash.String() != "b9d69064b190e7aedccf84731ca1d917871f8a1c" {
+ node, err := fileIndex.GetNodeByIndex(i)
+ c.Assert(err, IsNil)
+ memoryIndex.Add(hash, node)
+ }
+ }
+
+ nodeIndex := NewGraphCommitNodeIndex(memoryIndex, storer)
+ testWalker(c, nodeIndex)
+ testParents(c, nodeIndex)
+}