| 76 | } |
| 77 | |
| 78 | pub async fn add_all(repo_path: &Path) -> Result<(), String> { |
| 79 | tokio::task::spawn_blocking({ |
| 80 | let repo_path = repo_path.to_owned(); |
| 81 | move || -> Result<(), String> { |
| 82 | let output = std::process::Command::new("git") |
| 83 | .current_dir(&repo_path) |
| 84 | .arg("add") |
| 85 | .arg("-A") |
| 86 | .output() |
| 87 | .map_err(|e| format!("Failed to execute git add: {e}"))?; |
| 88 | |
| 89 | if !output.status.success() { |
| 90 | return Err(format!( |
| 91 | "Failed to add files to index: {}", |
| 92 | String::from_utf8_lossy(&output.stderr) |
| 93 | )); |
| 94 | } |
| 95 | |
| 96 | Ok(()) |
| 97 | } |
| 98 | }) |
| 99 | .await |
| 100 | .map_err(|e| format!("Task join error: {e}"))? |
| 101 | } |
| 102 | |
| 103 | /// Re-normalizes the index so that clean/smudge filters (e.g. git-lfs) are |
| 104 | /// re-applied. This fixes stat-cache mismatches after overlaying working |