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

Function restore_head

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

Source from the content-addressed store, hash-verified

2032}
2033
2034fn restore_head(git_repo: &GitRepository, snapshot: &ReferenceSnapshot) -> Result<(), git2::Error> {
2035 match snapshot {
2036 ReferenceSnapshot::Missing => match git_repo.find_reference("HEAD") {
2037 Ok(mut reference) => reference.delete(),
2038 Err(error) if error.code() == git2::ErrorCode::NotFound => Ok(()),
2039 Err(error) => Err(error),
2040 },
2041 ReferenceSnapshot::Direct(target) => git_repo.set_head_detached(*target),
2042 ReferenceSnapshot::Symbolic(target) => git_repo.set_head(target),
2043 }
2044}
2045
2046fn restore_reference(
2047 git_repo: &GitRepository,

Callers 1

restoreMethod · 0.85

Calls 2

deleteMethod · 0.45
codeMethod · 0.45

Tested by

no test coverage detected