1use std::{borrow::Cow, ffi::OsString, path::Path};
2
3use crate::Source;
4
5impl Source {
6 pub fn storage_location(self, env_var: &mut dyn FnMut(&str) -> Option<OsString>) -> Option<Cow<'static, Path>> {
11 use Source::*;
12 Some(match self {
13 GitInstallation => gix_path::env::installation_config_prefix()?
14 .join("gitattributes")
15 .into(),
16 System => {
17 if env_var("GIT_ATTR_NOSYSTEM").is_some() {
18 return None;
19 } else {
20 gix_path::env::system_prefix()?.join("etc/gitattributes").into()
21 }
22 }
23 Git => return gix_path::env::xdg_config("attributes", env_var).map(Cow::Owned),
24 Local => Cow::Borrowed(Path::new("info/attributes")),
25 })
26 }
27}