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

Function GitDir

git/git.go:859–877  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

857}
858
859func GitDir() (string, error) {
860 cmd, err := gitNoLFS("rev-parse", "--git-dir")
861 if err != nil {
862 // The %w format specifier is unique to fmt.Errorf(), so we
863 // do not pass it to tr.Tr.Get().
864 return "", fmt.Errorf("%s: %w", tr.Tr.Get("failed to find `git rev-parse --git-dir`"), err)
865 }
866 buf := &bytes.Buffer{}
867 cmd.Stderr = buf
868 out, err := cmd.Output()
869
870 if err != nil {
871 // The %w format specifier is unique to fmt.Errorf(), so we
872 // do not pass it to tr.Tr.Get().
873 return "", fmt.Errorf("%s: %w %v: %v", tr.Tr.Get("failed to call `git rev-parse --git-dir`"), err, string(out), buf.String())
874 }
875 path := strings.TrimSpace(string(out))
876 return tools.CanonicalizePath(path, false)
877}
878
879func GitCommonDir() (string, error) {
880 // Versions before 2.5.0 don't have the --git-common-dir option, since

Callers 4

dedupCommandFunction · 0.92
NewEndpointFinderFunction · 0.92
GitAndRootDirsFunction · 0.85
GitCommonDirFunction · 0.85

Calls 6

CanonicalizePathFunction · 0.92
gitNoLFSFunction · 0.85
ErrorfMethod · 0.65
GetMethod · 0.65
StringMethod · 0.65
OutputMethod · 0.45

Tested by

no test coverage detected