MCPcopy
hub / github.com/go-git/go-git / PlainOpenWithOptions

Function PlainOpenWithOptions

repository.go:310–339  ·  view source on GitHub ↗

PlainOpenWithOptions opens a git repository from the given path with specific options. See PlainOpen for more info.

(path string, o *PlainOpenOptions)

Source from the content-addressed store, hash-verified

308// PlainOpenWithOptions opens a git repository from the given path with specific
309// options. See PlainOpen for more info.
310func PlainOpenWithOptions(path string, o *PlainOpenOptions) (*Repository, error) {
311 dot, wt, err := dotGitToOSFilesystems(path, o.DetectDotGit)
312 if err != nil {
313 return nil, err
314 }
315
316 if _, err := dot.Stat(""); err != nil {
317 if os.IsNotExist(err) {
318 return nil, ErrRepositoryNotExists
319 }
320
321 return nil, err
322 }
323
324 var repositoryFs billy.Filesystem
325
326 if o.EnableDotGitCommonDir {
327 dotGitCommon, err := dotGitCommonDirectory(dot)
328 if err != nil {
329 return nil, err
330 }
331 repositoryFs = dotgit.NewRepositoryFilesystem(dot, dotGitCommon)
332 } else {
333 repositoryFs = dot
334 }
335
336 s := filesystem.NewStorage(repositoryFs, cache.NewObjectLRUDefault())
337
338 return Open(s, wt)
339}
340
341func dotGitToOSFilesystems(path string, detect bool) (dot, wt billy.Filesystem, err error) {
342 path, err = path_util.ReplaceTildeWithHome(path)

Callers 4

PlainOpenFunction · 0.85
TestLinkedWorktreeMethod · 0.85

Calls 7

NewRepositoryFilesystemFunction · 0.92
NewStorageFunction · 0.92
NewObjectLRUDefaultFunction · 0.92
dotGitToOSFilesystemsFunction · 0.85
dotGitCommonDirectoryFunction · 0.85
OpenFunction · 0.85
StatMethod · 0.65

Tested by 3

TestLinkedWorktreeMethod · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…