MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / conversion_policy

Function conversion_policy

atomic-cli/src/commands/git/parallel.rs:1664–1699  ·  view source on GitHub ↗
(git: &GitRepository)

Source from the content-addressed store, hash-verified

1662}
1663
1664pub(crate) fn conversion_policy(git: &GitRepository) -> CliResult<ConversionPolicy> {
1665 let config = git
1666 .config()
1667 .map_err(|error| git_error(format!("cannot read Git configuration: {error}")))?;
1668 let object_format = match config.get_string("extensions.objectFormat") {
1669 Ok(value) if value.eq_ignore_ascii_case("sha1") => GitHashAlgorithm::Sha1,
1670 Ok(value) if value.eq_ignore_ascii_case("sha256") => GitHashAlgorithm::Sha256,
1671 Ok(value) => {
1672 return Err(git_error(format!(
1673 "unsupported Git object algorithm '{value}'"
1674 )))
1675 }
1676 Err(error) if error.code() == git2::ErrorCode::NotFound => GitHashAlgorithm::Sha1,
1677 Err(error) => {
1678 return Err(git_error(format!(
1679 "cannot read Git object algorithm: {error}"
1680 )))
1681 }
1682 };
1683 let mut policy = ConversionPolicy::new(object_format);
1684 policy.platform = PlatformCapabilities {
1685 lossless_unix_paths: cfg!(unix),
1686 symlinks: config.get_bool("core.symlinks").unwrap_or(cfg!(unix)),
1687 executable_bit: config.get_bool("core.filemode").unwrap_or(cfg!(unix)),
1688 case_sensitive: !config.get_bool("core.ignorecase").unwrap_or(false),
1689 unicode_normalizing: config.get_bool("core.precomposeunicode").unwrap_or(false),
1690 };
1691 // RFC §6.2: `.vault/` is private by default but may be tracked under
1692 // explicit policy. Resolve the vault half from the recorded repository
1693 // configuration, then the tracked Git HEAD tree, so every command that
1694 // builds this policy agrees with the import that synthesized the
1695 // projection. Fails closed on a corrupt configuration.
1696 policy.exclusions = ExclusionPolicy::resolve_for_git(git)
1697 .map_err(|error| git_error(format!("cannot resolve the shim vault policy: {error}")))?;
1698 Ok(policy)
1699}
1700
1701/// Record the vault projection policy (RFC §6.2) for a freshly imported
1702/// repository.

Calls 2

git_errorFunction · 0.70
codeMethod · 0.45