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

Function dotGitCommonDirectory

repository.go:421–451  ·  view source on GitHub ↗
(fs billy.Filesystem)

Source from the content-addressed store, hash-verified

419}
420
421func dotGitCommonDirectory(fs billy.Filesystem) (commonDir billy.Filesystem, err error) {
422 f, err := fs.Open("commondir")
423 if os.IsNotExist(err) {
424 return nil, nil
425 }
426 if err != nil {
427 return nil, err
428 }
429
430 b, err := io.ReadAll(f)
431 if err != nil {
432 return nil, err
433 }
434 if len(b) > 0 {
435 path := strings.TrimSpace(string(b))
436 if filepath.IsAbs(path) {
437 commonDir = osfs.New(path)
438 } else {
439 commonDir = osfs.New(filepath.Join(fs.Root(), path))
440 }
441 if _, err := commonDir.Stat(""); err != nil {
442 if os.IsNotExist(err) {
443 return nil, ErrRepositoryIncomplete
444 }
445
446 return nil, err
447 }
448 }
449
450 return commonDir, nil
451}
452
453// PlainClone a repository into the path with the given options, isBare defines
454// if the new repository will be bare or normal. If the path is not empty

Callers 1

PlainOpenWithOptionsFunction · 0.85

Calls 4

JoinMethod · 0.80
RootMethod · 0.80
StatMethod · 0.80
OpenMethod · 0.45

Tested by

no test coverage detected