Fix staging error reporting (#25630)

Closes #ISSUE

Release Notes:

- N/A
This commit is contained in:
Conrad Irwin 2025-02-26 12:38:04 -07:00 committed by GitHub
parent 089ea5da50
commit b2a685f00a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 40 additions and 24 deletions

View file

@ -358,24 +358,30 @@ impl GitRepository for RealGitRepository {
log::debug!("indexing SHA: {sha}, path {path:?}");
let status = new_std_command(&self.git_binary_path)
let output = new_std_command(&self.git_binary_path)
.current_dir(&working_directory)
.args(["update-index", "--add", "--cacheinfo", "100644", &sha])
.arg(path.as_ref())
.status()?;
.output()?;
if !status.success() {
return Err(anyhow!("Failed to add to index: {status:?}"));
if !output.status.success() {
return Err(anyhow!(
"Failed to stage:\n{}",
String::from_utf8_lossy(&output.stderr)
));
}
} else {
let status = new_std_command(&self.git_binary_path)
let output = new_std_command(&self.git_binary_path)
.current_dir(&working_directory)
.args(["update-index", "--force-remove"])
.arg(path.as_ref())
.status()?;
.output()?;
if !status.success() {
return Err(anyhow!("Failed to remove from index: {status:?}"));
if !output.status.success() {
return Err(anyhow!(
"Failed to unstage:\n{}",
String::from_utf8_lossy(&output.stderr)
));
}
}