(oid: Oid)
| 165 | } |
| 166 | |
| 167 | fn canonical_ref_target(oid: Oid) -> Option<GitRefTarget> { |
| 168 | let bytes = oid.as_bytes().to_vec(); |
| 169 | let algorithm = match bytes.len() { |
| 170 | 20 => GitHashAlgorithm::Sha1, |
| 171 | 32 => GitHashAlgorithm::Sha256, |
| 172 | _ => return None, |
| 173 | }; |
| 174 | GitObjectId::new(algorithm, bytes) |
| 175 | .ok() |
| 176 | .map(GitRefTarget::Direct) |
| 177 | } |
| 178 | |
| 179 | /// Journal an expected-absent ref creation, perform it through a real Git |
| 180 | /// reference transaction, then record its leased receipt and verify. |