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

Commit 7104281

Browse files
committed
test: git alternates
1 parent 290fd74 commit 7104281

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

worktree_test.go

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1287,3 +1287,33 @@ func (s *WorktreeSuite) TestClean(c *C) {
12871287

12881288
c.Assert(len(status), Equals, 0)
12891289
}
1290+
1291+
func (s *WorktreeSuite) TestAlternatesRepo(c *C) {
1292+
fs := fixtures.ByTag("alternates").One().Worktree()
1293+
1294+
// Open 1st repo.
1295+
rep1fs, err := fs.Chroot("rep1")
1296+
c.Assert(err, IsNil)
1297+
rep1, err := PlainOpen(rep1fs.Root())
1298+
c.Assert(err, IsNil)
1299+
1300+
// Open 2nd repo.
1301+
rep2fs, err := fs.Chroot("rep2")
1302+
c.Assert(err, IsNil)
1303+
rep2, err := PlainOpen(rep2fs.Root())
1304+
c.Assert(err, IsNil)
1305+
1306+
// Get the HEAD commit from the main repo.
1307+
h, err := rep1.Head()
1308+
c.Assert(err, IsNil)
1309+
commit1, err := rep1.CommitObject(h.Hash())
1310+
c.Assert(err, IsNil)
1311+
1312+
// Get the HEAD commit from the shared repo.
1313+
h, err = rep2.Head()
1314+
c.Assert(err, IsNil)
1315+
commit2, err := rep2.CommitObject(h.Hash())
1316+
c.Assert(err, IsNil)
1317+
1318+
c.Assert(commit1.String(), Equals, commit2.String())
1319+
}

0 commit comments

Comments
 (0)