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

Commit 0c23406

Browse files
committed
test: git alternates
1 parent 30c2ad5 commit 0c23406

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
@@ -1252,3 +1252,33 @@ func (s *WorktreeSuite) TestMoveToExistent(c *C) {
12521252
c.Assert(hash.IsZero(), Equals, true)
12531253
c.Assert(err, Equals, ErrDestinationExists)
12541254
}
1255+
1256+
func (s *WorktreeSuite) TestAlternatesRepo(c *C) {
1257+
fs := fixtures.ByTag("alternates").One().Worktree()
1258+
1259+
// Open 1st repo.
1260+
rep1fs, err := fs.Chroot("rep1")
1261+
c.Assert(err, IsNil)
1262+
rep1, err := PlainOpen(rep1fs.Root())
1263+
c.Assert(err, IsNil)
1264+
1265+
// Open 2nd repo.
1266+
rep2fs, err := fs.Chroot("rep2")
1267+
c.Assert(err, IsNil)
1268+
rep2, err := PlainOpen(rep2fs.Root())
1269+
c.Assert(err, IsNil)
1270+
1271+
// Get the HEAD commit from the main repo.
1272+
h, err := rep1.Head()
1273+
c.Assert(err, IsNil)
1274+
commit1, err := rep1.CommitObject(h.Hash())
1275+
c.Assert(err, IsNil)
1276+
1277+
// Get the HEAD commit from the shared repo.
1278+
h, err = rep2.Head()
1279+
c.Assert(err, IsNil)
1280+
commit2, err := rep2.CommitObject(h.Hash())
1281+
c.Assert(err, IsNil)
1282+
1283+
c.Assert(commit1.String(), Equals, commit2.String())
1284+
}

0 commit comments

Comments
 (0)