()
| 877 | } |
| 878 | |
| 879 | func GitCommonDir() (string, error) { |
| 880 | // Versions before 2.5.0 don't have the --git-common-dir option, since |
| 881 | // it came in with worktrees, so just fall back to the main Git |
| 882 | // directory. |
| 883 | if !IsGitVersionAtLeast("2.5.0") { |
| 884 | return GitDir() |
| 885 | } |
| 886 | |
| 887 | cmd, err := gitNoLFS("rev-parse", "--git-common-dir") |
| 888 | if err != nil { |
| 889 | return "", errors.New(tr.Tr.Get("failed to find `git rev-parse --git-common-dir`: %v", err)) |
| 890 | } |
| 891 | out, err := cmd.Output() |
| 892 | buf := &bytes.Buffer{} |
| 893 | cmd.Stderr = buf |
| 894 | if err != nil { |
| 895 | return "", errors.New(tr.Tr.Get("failed to call `git rev-parse --git-common-dir`: %v %v: %v", err, string(out), buf.String())) |
| 896 | } |
| 897 | path := strings.TrimSpace(string(out)) |
| 898 | path, err = tools.TranslateCygwinPath(path) |
| 899 | if err != nil { |
| 900 | return "", err |
| 901 | } |
| 902 | return tools.CanonicalizePath(path, false) |
| 903 | } |
| 904 | |
| 905 | // A git worktree (ref + path + flags) |
| 906 | type Worktree struct { |
no test coverage detected