MCPcopy Create free account
hub / github.com/go-git/go-git / TestAlternatesRepo

Function TestAlternatesRepo

worktree_test.go:2400–2434  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

2398}
2399
2400func TestAlternatesRepo(t *testing.T) {
2401 fs := fixtures.ByTag("alternates").One().Worktree()
2402
2403 // Open 1st repo.
2404 rep1fs, err := fs.Chroot("rep1")
2405 assert.NoError(t, err)
2406 rep1, err := PlainOpen(rep1fs.Root())
2407 assert.NoError(t, err)
2408
2409 // Open 2nd repo.
2410 rep2fs, err := fs.Chroot("rep2")
2411 assert.NoError(t, err)
2412 d, _ := rep2fs.Chroot(GitDirName)
2413 storer := filesystem.NewStorageWithOptions(d,
2414 cache.NewObjectLRUDefault(), filesystem.Options{
2415 AlternatesFS: fs,
2416 })
2417 rep2, err := Open(storer, rep2fs)
2418
2419 assert.NoError(t, err)
2420
2421 // Get the HEAD commit from the main repo.
2422 h, err := rep1.Head()
2423 assert.NoError(t, err)
2424 commit1, err := rep1.CommitObject(h.Hash())
2425 assert.NoError(t, err)
2426
2427 // Get the HEAD commit from the shared repo.
2428 h, err = rep2.Head()
2429 assert.NoError(t, err)
2430 commit2, err := rep2.CommitObject(h.Hash())
2431 assert.NoError(t, err)
2432
2433 assert.Equal(t, commit1.String(), commit2.String())
2434}
2435
2436func (s *WorktreeSuite) TestGrep(c *C) {
2437 cases := []struct {

Callers

nothing calls this directly

Calls 11

NewStorageWithOptionsFunction · 0.92
NewObjectLRUDefaultFunction · 0.92
PlainOpenFunction · 0.85
OpenFunction · 0.85
WorktreeMethod · 0.80
ChrootMethod · 0.80
RootMethod · 0.80
HeadMethod · 0.80
CommitObjectMethod · 0.80
HashMethod · 0.65
StringMethod · 0.65

Tested by

no test coverage detected