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

Function restore_index

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

Source from the content-addressed store, hash-verified

1876}
1877
1878fn restore_index(git_repo: &GitRepository, bytes: Option<&[u8]>) -> std::io::Result<()> {
1879 let index_path = git_repo.path().join("index");
1880 match bytes {
1881 Some(bytes) => std::fs::write(index_path, bytes),
1882 None => match std::fs::remove_file(index_path) {
1883 Ok(()) => Ok(()),
1884 Err(error) if error.kind() == std::io::ErrorKind::NotFound => Ok(()),
1885 Err(error) => Err(error),
1886 },
1887 }
1888}
1889
1890fn git_error(message: impl Into<String>) -> CliError {
1891 CliError::GitError {

Callers 1

restoreMethod · 0.85

Calls 3

writeFunction · 0.50
pathMethod · 0.45
kindMethod · 0.45

Tested by

no test coverage detected