| 68 | } |
| 69 | |
| 70 | fn direct_target(oid: git2::Oid) -> Result<GitRefTarget, RepositoryError> { |
| 71 | let algorithm = match oid.as_bytes().len() { |
| 72 | 20 => atomic_core::operation::GitHashAlgorithm::Sha1, |
| 73 | 32 => atomic_core::operation::GitHashAlgorithm::Sha256, |
| 74 | other => return Err(git_map(format!("unexpected Git OID width {other}"))), |
| 75 | }; |
| 76 | let object = atomic_core::operation::GitObjectId::new(algorithm, oid.as_bytes().to_vec()) |
| 77 | .map_err(|error| git_map(error.to_string()))?; |
| 78 | Ok(GitRefTarget::Direct(object)) |
| 79 | } |
| 80 | |
| 81 | fn read_ref(git: &GitRepository, name: &str) -> Result<Option<GitRefTarget>, RepositoryError> { |
| 82 | match git.find_reference(name) { |