Skip to main content

resolve_hash_type

Function resolve_hash_type 

Source
pub(crate) fn resolve_hash_type(
    repo_path: &Path,
    cli_hash: Option<HashType>,
    upgrade: bool,
) -> Result<HashType>
Expand description

Determine the effective hash type for a repository.

Resolution order:

  1. If meta.json exists, use its algorithm. Error if --hash was explicitly passed and conflicts.
  2. If no metadata and upgrade is true, infer from existing objects.
  3. If no metadata and upgrade is false, error.

Note: we read the metadata file directly here (rather than via Repository::metadata) because this runs before we know which generic ObjectID type to use — that’s exactly what we’re deciding.