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

Function restore_reference

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

Source from the content-addressed store, hash-verified

2044}
2045
2046fn restore_reference(
2047 git_repo: &GitRepository,
2048 name: &str,
2049 snapshot: &ReferenceSnapshot,
2050) -> Result<(), git2::Error> {
2051 match snapshot {
2052 ReferenceSnapshot::Missing => match git_repo.find_reference(name) {
2053 Ok(mut reference) => reference.delete(),
2054 Err(error) if error.code() == git2::ErrorCode::NotFound => Ok(()),
2055 Err(error) => Err(error),
2056 },
2057 ReferenceSnapshot::Direct(target) => git_repo
2058 .reference(name, *target, true, "restore failed Atomic shadow switch")
2059 .map(|_| ()),
2060 ReferenceSnapshot::Symbolic(target) => git_repo
2061 .reference_symbolic(name, target, true, "restore failed Atomic shadow switch")
2062 .map(|_| ()),
2063 }
2064}
2065
2066fn restore_index(git_repo: &GitRepository, bytes: Option<&[u8]>) -> std::io::Result<()> {
2067 let index_path = git_repo.path().join("index");

Callers 1

restoreMethod · 0.85

Calls 3

deleteMethod · 0.45
codeMethod · 0.45
referenceMethod · 0.45

Tested by

no test coverage detected