Skip to content
This repository was archived by the owner on Sep 11, 2020. It is now read-only.

Commit cc48439

Browse files
committed
Add test for traversal on mixed object and commit-graph
Signed-off-by: Filip Navara <filip.navara@gmail.com>
1 parent b48e486 commit cc48439

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

plumbing/object/commitnode_test.go

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,3 +102,33 @@ func (s *CommitNodeSuite) TestCommitGraph(c *C) {
102102
testWalker(c, nodeIndex)
103103
testParents(c, nodeIndex)
104104
}
105+
106+
func (s *CommitNodeSuite) TestMixedGraph(c *C) {
107+
// Unpack the original repository with pack file
108+
f := fixtures.ByTag("commit-graph").One()
109+
dotgit := f.DotGit()
110+
storer := filesystem.NewStorage(dotgit, cache.NewObjectLRUDefault())
111+
p := f.Packfile()
112+
defer p.Close()
113+
err := packfile.UpdateObjectStorage(storer, p)
114+
c.Assert(err, IsNil)
115+
116+
// Take the commit-graph file and copy it to memory index without the last commit
117+
reader, err := mmap.Open(path.Join(dotgit.Root(), "objects", "info", "commit-graph"))
118+
c.Assert(err, IsNil)
119+
defer reader.Close()
120+
fileIndex, err := commitgraph.OpenFileIndex(reader)
121+
c.Assert(err, IsNil)
122+
memoryIndex := commitgraph.NewMemoryIndex()
123+
for i, hash := range fileIndex.Hashes() {
124+
if hash.String() != "b9d69064b190e7aedccf84731ca1d917871f8a1c" {
125+
node, err := fileIndex.GetNodeByIndex(i)
126+
c.Assert(err, IsNil)
127+
memoryIndex.Add(hash, node)
128+
}
129+
}
130+
131+
nodeIndex := NewGraphCommitNodeIndex(memoryIndex, storer)
132+
testWalker(c, nodeIndex)
133+
testParents(c, nodeIndex)
134+
}

0 commit comments

Comments
 (0)