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

Function GetSystemAttributePaths

git/attribs.go:70–100  ·  view source on GitHub ↗

GetSystemAttributePaths behaves as GetAttributePaths, and loads information only from the system gitattributes file, respecting the $PREFIX environment variable.

(mp *gitattr.MacroProcessor, env Env)

Source from the content-addressed store, hash-verified

68// only from the system gitattributes file, respecting the $PREFIX environment
69// variable.
70func GetSystemAttributePaths(mp *gitattr.MacroProcessor, env Env) ([]AttributePath, error) {
71 var path string
72 if IsGitVersionAtLeast("2.42.0") {
73 cmd, err := gitNoLFS("var", "GIT_ATTR_SYSTEM")
74 if err != nil {
75 return nil, errors.New(tr.Tr.Get("failed to find `git var GIT_ATTR_SYSTEM`: %v", err))
76 }
77 out, err := cmd.Output()
78 if err != nil {
79 return nil, errors.New(tr.Tr.Get("failed to call `git var GIT_ATTR_SYSTEM`: %v", err))
80 }
81 paths := strings.Split(string(out), "\n")
82 if len(paths) == 0 {
83 return nil, nil
84 }
85 path = paths[0]
86 } else {
87 prefix, _ := env.Get("PREFIX")
88 if len(prefix) == 0 {
89 prefix = string(filepath.Separator)
90 }
91
92 path = filepath.Join(prefix, "etc", "gitattributes")
93 }
94
95 if _, err := os.Stat(path); os.IsNotExist(err) {
96 return nil, nil
97 }
98
99 return attrPathsFromFile(mp, path, "", true), nil
100}
101
102// GetAttributePaths returns a list of entries in .gitattributes which are
103// configured with the filter=lfs attribute

Callers 2

trackCommandFunction · 0.92
getAllKnownPatternsFunction · 0.92

Calls 5

IsGitVersionAtLeastFunction · 0.85
gitNoLFSFunction · 0.85
attrPathsFromFileFunction · 0.85
GetMethod · 0.65
OutputMethod · 0.45

Tested by

no test coverage detected