GetSystemAttributePaths behaves as GetAttributePaths, and loads information only from the system gitattributes file, respecting the $PREFIX environment variable.
(mp *gitattr.MacroProcessor, env Env)
| 68 | // only from the system gitattributes file, respecting the $PREFIX environment |
| 69 | // variable. |
| 70 | func 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 |
no test coverage detected