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

Function dotGitCommonDirectory

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

Source from the content-addressed store, hash-verified

426}
427
428func dotGitCommonDirectory(fs billy.Filesystem) (commonDir billy.Filesystem, err error) {
429 f, err := fs.Open("commondir")
430 if os.IsNotExist(err) {
431 return nil, nil
432 }
433 if err != nil {
434 return nil, err
435 }
436
437 b, err := io.ReadAll(f)
438 if err != nil {
439 return nil, err
440 }
441 if len(b) > 0 {
442 path := strings.TrimSpace(string(b))
443 if filepath.IsAbs(path) {
444 commonDir = osfs.New(path)
445 } else {
446 commonDir = osfs.New(filepath.Join(fs.Root(), path))
447 }
448 if _, err := commonDir.Stat(""); err != nil {
449 if os.IsNotExist(err) {
450 return nil, ErrRepositoryIncomplete
451 }
452
453 return nil, err
454 }
455 }
456
457 return commonDir, nil
458}
459
460// PlainClone a repository into the path with the given options, isBare defines
461// 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.65
OpenMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…