| 1876 | } |
| 1877 | |
| 1878 | fn 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 | |
| 1890 | fn git_error(message: impl Into<String>) -> CliError { |
| 1891 | CliError::GitError { |