PlainOpenWithOptions opens a git repository from the given path with specific options. See PlainOpen for more info.
(path string, o *PlainOpenOptions)
| 308 | // PlainOpenWithOptions opens a git repository from the given path with specific |
| 309 | // options. See PlainOpen for more info. |
| 310 | func 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 | |
| 341 | func dotGitToOSFilesystems(path string, detect bool) (dot, wt billy.Filesystem, err error) { |
| 342 | path, err = path_util.ReplaceTildeWithHome(path) |
searching dependent graphs…