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