| 2064 | } |
| 2065 | |
| 2066 | fn 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 | |
| 2078 | fn git_error(message: impl Into<String>) -> CliError { |
| 2079 | CliError::GitError { |