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

Function restore_index

atomic-cli/src/commands/git/shadow.rs:2066–2076  ·  view source on GitHub ↗
(git_repo: &GitRepository, bytes: Option<&[u8]>)

Source from the content-addressed store, hash-verified

2064}
2065
2066fn restore_index(git_repo: &GitRepository, bytes: Option<&[u8]>) -> std::io::Result<()> {
2067 let index_path = git_repo.path().join("index");
2068 match bytes {
2069 Some(bytes) => std::fs::write(index_path, bytes),
2070 None => match std::fs::remove_file(index_path) {
2071 Ok(()) => Ok(()),
2072 Err(error) if error.kind() == std::io::ErrorKind::NotFound => Ok(()),
2073 Err(error) => Err(error),
2074 },
2075 }
2076}
2077
2078fn git_error(message: impl Into<String>) -> CliError {
2079 CliError::GitError {

Callers 1

restoreMethod · 0.85

Calls 3

writeFunction · 0.50
pathMethod · 0.45
kindMethod · 0.45

Tested by

no test coverage detected