MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / load_binding_at_ref

Function load_binding_at_ref

atomic-cli/src/commands/git/bootstrap.rs:308–339  ·  view source on GitHub ↗

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,
)

Source from the content-addressed store, hash-verified

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).
308fn 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

Callers 1

install_binding_refsFunction · 0.70

Calls 4

treeMethod · 0.80
decodeFunction · 0.50
idMethod · 0.45
contentMethod · 0.45

Tested by

no test coverage detected