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

Function PlainOpenWithOptions

repository.go:303–332  ·  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

301// PlainOpenWithOptions opens a git repository from the given path with specific
302// options. See PlainOpen for more info.
303func PlainOpenWithOptions(path string, o *PlainOpenOptions) (*Repository, error) {
304 dot, wt, err := dotGitToOSFilesystems(path, o.DetectDotGit)
305 if err != nil {
306 return nil, err
307 }
308
309 if _, err := dot.Stat(""); err != nil {
310 if os.IsNotExist(err) {
311 return nil, ErrRepositoryNotExists
312 }
313
314 return nil, err
315 }
316
317 var repositoryFs billy.Filesystem
318
319 if o.EnableDotGitCommonDir {
320 dotGitCommon, err := dotGitCommonDirectory(dot)
321 if err != nil {
322 return nil, err
323 }
324 repositoryFs = dotgit.NewRepositoryFilesystem(dot, dotGitCommon)
325 } else {
326 repositoryFs = dot
327 }
328
329 s := filesystem.NewStorage(repositoryFs, cache.NewObjectLRUDefault())
330
331 return Open(s, wt)
332}
333
334func dotGitToOSFilesystems(path string, detect bool) (dot, wt billy.Filesystem, err error) {
335 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.80

Tested by 3

TestLinkedWorktreeMethod · 0.68