Decode the binding blob from a binding-commit tree (the reviewed allowlisted blob; the tree confine check in the store reader applies at restore time, and this loader reads only the canonical binding blob).
(
git: &GitRepository,
ref_name: &str,
target: git2::Oid,
)
| 306 | /// allowlisted blob; the tree confine check in the store reader applies at |
| 307 | /// restore time, and this loader reads only the canonical binding blob). |
| 308 | fn load_binding_at_ref( |
| 309 | git: &GitRepository, |
| 310 | ref_name: &str, |
| 311 | target: git2::Oid, |
| 312 | ) -> CliResult<GitStateBinding> { |
| 313 | let commit = git |
| 314 | .find_commit(target) |
| 315 | .map_err(|error| CliError::GitError { |
| 316 | message: format!("binding ref '{ref_name}' points at a missing commit: {error}"), |
| 317 | })?; |
| 318 | let tree = commit.tree().map_err(|error| CliError::GitError { |
| 319 | message: format!("binding ref '{ref_name}' commit has no tree: {error}"), |
| 320 | })?; |
| 321 | let entry = tree |
| 322 | .get_name(BINDING_BLOB_NAME) |
| 323 | .ok_or_else(|| CliError::GitError { |
| 324 | message: format!("binding ref '{ref_name}' tree does not contain {BINDING_BLOB_NAME}"), |
| 325 | })?; |
| 326 | if entry.filemode() != i32::from(git2::FileMode::Blob) { |
| 327 | return Err(CliError::GitError { |
| 328 | message: format!("binding ref '{ref_name}' entry is not a regular blob"), |
| 329 | }); |
| 330 | } |
| 331 | let blob = git |
| 332 | .find_blob(entry.id()) |
| 333 | .map_err(|error| CliError::GitError { |
| 334 | message: format!("binding ref '{ref_name}' blob is missing: {error}"), |
| 335 | })?; |
| 336 | GitStateBinding::decode(blob.content()).map_err(|error| CliError::GitError { |
| 337 | message: format!("binding ref '{ref_name}' carries undecodable binding bytes: {error}"), |
| 338 | }) |
| 339 | } |
| 340 | |
| 341 | /// The shared bound bootstrap for an existing Git checkout (RFC §7.3 via the |
| 342 | /// CB-7A anchor machinery). `key_file` signs the Anchor when supplied; the |
no test coverage detected