(directory: &Path, git_dir: &Path, args: &[&str])
| 227 | } |
| 228 | |
| 229 | fn git_output(directory: &Path, git_dir: &Path, args: &[&str]) -> Result<Output> { |
| 230 | let output = Command::new("git") |
| 231 | .arg("--git-dir") |
| 232 | .arg(git_dir) |
| 233 | .arg("--work-tree") |
| 234 | .arg(directory) |
| 235 | .args(args) |
| 236 | .current_dir(directory) |
| 237 | .output() |
| 238 | .with_context(|| format!("failed to run git command: git {}", args.join(" ")))?; |
| 239 | |
| 240 | if !output.status.success() { |
| 241 | anyhow::bail!( |
| 242 | "git command failed: git {}: {}", |
| 243 | args.join(" "), |
| 244 | String::from_utf8_lossy(&output.stderr).trim() |
| 245 | ); |
| 246 | } |
| 247 | |
| 248 | Ok(output) |
| 249 | } |
| 250 | |
| 251 | fn git_add_all(directory: &Path, git_dir: &Path) -> Result<()> { |
| 252 | // Exclude the snapshot repo itself when it lives under worktree. |
no test coverage detected