MCPcopy Index your code
hub / github.com/go-git/go-git / TestAlternatesRepo

Function TestAlternatesRepo

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

Source from the content-addressed store, hash-verified

2655}
2656
2657func TestAlternatesRepo(t *testing.T) {
2658 fs := fixtures.ByTag("alternates").One().Worktree()
2659
2660 // Open 1st repo.
2661 rep1fs, err := fs.Chroot("rep1")
2662 assert.NoError(t, err)
2663 rep1, err := PlainOpen(rep1fs.Root())
2664 assert.NoError(t, err)
2665
2666 // Open 2nd repo.
2667 rep2fs, err := fs.Chroot("rep2")
2668 assert.NoError(t, err)
2669 d, _ := rep2fs.Chroot(GitDirName)
2670 storer := filesystem.NewStorageWithOptions(d,
2671 cache.NewObjectLRUDefault(), filesystem.Options{
2672 AlternatesFS: fs,
2673 })
2674 rep2, err := Open(storer, rep2fs)
2675
2676 assert.NoError(t, err)
2677
2678 // Get the HEAD commit from the main repo.
2679 h, err := rep1.Head()
2680 assert.NoError(t, err)
2681 commit1, err := rep1.CommitObject(h.Hash())
2682 assert.NoError(t, err)
2683
2684 // Get the HEAD commit from the shared repo.
2685 h, err = rep2.Head()
2686 assert.NoError(t, err)
2687 commit2, err := rep2.CommitObject(h.Hash())
2688 assert.NoError(t, err)
2689
2690 assert.Equal(t, commit1.String(), commit2.String())
2691}
2692
2693func (s *WorktreeSuite) TestGrep(c *C) {
2694 cases := []struct {

Callers

nothing calls this directly

Calls 11

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

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…