MCPcopy
hub / github.com/git-lfs/git-lfs / GitCommonDir

Function GitCommonDir

git/git.go:879–903  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

877}
878
879func 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)
906type Worktree struct {

Callers 2

getObjectDatabaseFunction · 0.92
NewObjectScannerFunction · 0.85

Calls 9

NewFunction · 0.92
TranslateCygwinPathFunction · 0.92
CanonicalizePathFunction · 0.92
IsGitVersionAtLeastFunction · 0.85
GitDirFunction · 0.85
gitNoLFSFunction · 0.85
GetMethod · 0.65
StringMethod · 0.65
OutputMethod · 0.45

Tested by

no test coverage detected