(oid: &git2::Oid)
| 856 | } |
| 857 | |
| 858 | fn git_object_id(oid: &git2::Oid) -> Result<GitObjectId, RepositoryError> { |
| 859 | let bytes = oid.as_bytes().to_vec(); |
| 860 | let algorithm = match bytes.len() { |
| 861 | 20 => GitHashAlgorithm::Sha1, |
| 862 | 32 => GitHashAlgorithm::Sha256, |
| 863 | other => return Err(git_map(format!("unexpected Git OID width {other}"))), |
| 864 | }; |
| 865 | GitObjectId::new(algorithm, bytes).map_err(|error| git_map(error.to_string())) |
| 866 | } |
| 867 | |
| 868 | fn git2_oid(oid: &GitObjectId) -> Result<git2::Oid, RepositoryError> { |
| 869 | git2::Oid::from_bytes(oid.as_bytes()).map_err(git_map) |
no test coverage detected