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

Function align_index_to_tree

atomic-cli/src/commands/git/shadow.rs:1796–1822  ·  view source on GitHub ↗
(
    git_repo: &GitRepository,
    tree_oid: git2::Oid,
    publication: &VerifiedPublication,
)

Source from the content-addressed store, hash-verified

1794}
1795
1796fn align_index_to_tree(
1797 git_repo: &GitRepository,
1798 tree_oid: git2::Oid,
1799 publication: &VerifiedPublication,
1800) -> CliResult<()> {
1801 if publication.git_tree_oid()? != tree_oid {
1802 return Err(git_error("refusing to align index to an unverified tree"));
1803 }
1804 let tree = git_repo.find_tree(tree_oid).map_err(|error| {
1805 git_error(format!(
1806 "cannot read shadow projection tree while aligning Git index: {error}"
1807 ))
1808 })?;
1809 let mut index = git_repo.index().map_err(|error| {
1810 git_error(format!(
1811 "cannot open Git index while aligning shadow view: {error}"
1812 ))
1813 })?;
1814 index
1815 .read_tree(&tree)
1816 .and_then(|_| index.write())
1817 .map_err(|error| {
1818 git_error(format!(
1819 "cannot align Git index to the shadow projection tree: {error}"
1820 ))
1821 })
1822}
1823
1824fn snapshot_reference(git_repo: &GitRepository, name: &str) -> CliResult<ReferenceSnapshot> {
1825 match git_repo.find_reference(name) {

Callers

nothing calls this directly

Calls 4

git_tree_oidMethod · 0.80
git_errorFunction · 0.70
indexMethod · 0.45
writeMethod · 0.45

Tested by

no test coverage detected