Skip to content

Commit c72ea8b

Browse files
committed
feat: respect the :(optional) prefix when interpolating confiurgation paths.
1 parent c2bc941 commit c72ea8b

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

gix/src/config/cache/access.rs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -544,7 +544,19 @@ pub(crate) fn trusted_file_path<'config>(
544544
let install_dir = crate::path::install_dir().ok();
545545
let home = home_dir(environment);
546546
let ctx = config::cache::interpolate_context(install_dir.as_deref(), home.as_deref());
547-
Some(path.interpolate(ctx))
547+
548+
let is_optional = path.is_optional;
549+
let res = path.interpolate(ctx);
550+
if is_optional {
551+
if let Ok(path) = &res {
552+
// As opposed to Git, for a lack of the right error variant, we ignore everything that can't
553+
// be stat'ed, instead of just checking if it doesn't exist via error code.
554+
if path.metadata().is_err() {
555+
return None;
556+
}
557+
}
558+
}
559+
Some(res)
548560
}
549561

550562
pub(crate) fn home_dir(environment: crate::open::permissions::Environment) -> Option<PathBuf> {

0 commit comments

Comments
 (0)