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

Function dotGitFileToOSFilesystem

repository.go:401–426  ·  view source on GitHub ↗
(path string, fs billy.Filesystem)

Source from the content-addressed store, hash-verified

399}
400
401func dotGitFileToOSFilesystem(path string, fs billy.Filesystem) (bfs billy.Filesystem, err error) {
402 f, err := fs.Open(GitDirName)
403 if err != nil {
404 return nil, err
405 }
406 defer ioutil.CheckClose(f, &err)
407
408 b, err := io.ReadAll(f)
409 if err != nil {
410 return nil, err
411 }
412
413 line := string(b)
414 const prefix = "gitdir: "
415 if !strings.HasPrefix(line, prefix) {
416 return nil, fmt.Errorf(".git file has no %s prefix", prefix)
417 }
418
419 gitdir := strings.Split(line[len(prefix):], "\n")[0]
420 gitdir = strings.TrimSpace(gitdir)
421 if filepath.IsAbs(gitdir) {
422 return osfs.New(gitdir), nil
423 }
424
425 return osfs.New(fs.Join(path, gitdir)), nil
426}
427
428func dotGitCommonDirectory(fs billy.Filesystem) (commonDir billy.Filesystem, err error) {
429 f, err := fs.Open("commondir")

Callers 1

dotGitToOSFilesystemsFunction · 0.85

Calls 3

CheckCloseFunction · 0.92
JoinMethod · 0.80
OpenMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…