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

Function restore_reference

atomic-cli/src/commands/git/shadow.rs:1858–1876  ·  view source on GitHub ↗
(
    git_repo: &GitRepository,
    name: &str,
    snapshot: &ReferenceSnapshot,
)

Source from the content-addressed store, hash-verified

1856}
1857
1858fn restore_reference(
1859 git_repo: &GitRepository,
1860 name: &str,
1861 snapshot: &ReferenceSnapshot,
1862) -> Result<(), git2::Error> {
1863 match snapshot {
1864 ReferenceSnapshot::Missing => match git_repo.find_reference(name) {
1865 Ok(mut reference) => reference.delete(),
1866 Err(error) if error.code() == git2::ErrorCode::NotFound => Ok(()),
1867 Err(error) => Err(error),
1868 },
1869 ReferenceSnapshot::Direct(target) => git_repo
1870 .reference(name, *target, true, "restore failed Atomic shadow switch")
1871 .map(|_| ()),
1872 ReferenceSnapshot::Symbolic(target) => git_repo
1873 .reference_symbolic(name, target, true, "restore failed Atomic shadow switch")
1874 .map(|_| ()),
1875 }
1876}
1877
1878fn restore_index(git_repo: &GitRepository, bytes: Option<&[u8]>) -> std::io::Result<()> {
1879 let index_path = git_repo.path().join("index");

Callers 1

restoreMethod · 0.85

Calls 3

referenceMethod · 0.80
deleteMethod · 0.45
codeMethod · 0.45

Tested by

no test coverage detected