| 709 | } |
| 710 | |
| 711 | fn load_binding_at_ref( |
| 712 | git: &GitRepository, |
| 713 | ref_name: &str, |
| 714 | target: git2::Oid, |
| 715 | ) -> CliResult<GitStateBinding> { |
| 716 | let commit = git.find_commit(target).map_err(|error| { |
| 717 | git_map(format!( |
| 718 | "binding ref '{ref_name}' points at a missing commit: {error}" |
| 719 | )) |
| 720 | })?; |
| 721 | let tree = commit |
| 722 | .tree() |
| 723 | .map_err(|error| git_map(format!("binding ref '{ref_name}' has no tree: {error}")))?; |
| 724 | let entry = tree.get_name("binding.cbor").ok_or_else(|| { |
| 725 | git_map(format!( |
| 726 | "binding ref '{ref_name}' does not carry binding.cbor" |
| 727 | )) |
| 728 | })?; |
| 729 | let blob = git |
| 730 | .find_blob(entry.id()) |
| 731 | .map_err(|error| git_map(format!("binding ref '{ref_name}' blob missing: {error}")))?; |
| 732 | GitStateBinding::decode(blob.content()).map_err(|error| { |
| 733 | git_map(format!( |
| 734 | "binding ref '{ref_name}' carries invalid binding bytes: {error}" |
| 735 | )) |
| 736 | }) |
| 737 | } |
| 738 | |
| 739 | /// Closure acquisition through the CLI (CB-6B, RFC §8.6): Atomic remote |
| 740 | /// first, the binding's bounded `changes.pack` as verified fallback. |