(root: &Path)
| 1293 | } |
| 1294 | |
| 1295 | fn read_shim_config(root: &Path) -> Result<atomic_config::RepoConfig, ShimConfigError> { |
| 1296 | let dir = atomic_repository::Repository::canonical_dot_dir(root) |
| 1297 | .map_err(|_| ShimConfigError::Location)?; |
| 1298 | // Reading directly avoids `Path::exists` treating access errors as an |
| 1299 | // absent config, while preserving the default for a genuinely missing file. |
| 1300 | let path = dir.join("config.toml"); |
| 1301 | match std::fs::read_to_string(&path) { |
| 1302 | Ok(text) => toml::from_str(&text).map_err(|_| ShimConfigError::Parse), |
| 1303 | Err(error) if error.kind() == ErrorKind::NotFound && demonstrably_missing(&path) => { |
| 1304 | Ok(Default::default()) |
| 1305 | } |
| 1306 | Err(error) => Err(ShimConfigError::Read(error.kind())), |
| 1307 | } |
| 1308 | } |
| 1309 | |
| 1310 | fn collect_git_shim( |
| 1311 | workspace: &Result<Option<PathBuf>, SourceError>, |
no test coverage detected