Fix git hunk staging on windows (#35755)

We were failing to flush the Git process's `stdin` before dropping it.

Release Notes:

- N/A
This commit is contained in:
Max Brunsfeld 2025-08-06 17:30:36 -07:00 committed by GitHub
parent 8e290b446e
commit c595a7576d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -846,14 +846,12 @@ impl GitRepository for RealGitRepository {
.stdin(Stdio::piped()) .stdin(Stdio::piped())
.stdout(Stdio::piped()) .stdout(Stdio::piped())
.spawn()?; .spawn()?;
child let mut stdin = child.stdin.take().unwrap();
.stdin stdin.write_all(content.as_bytes()).await?;
.take() stdin.flush().await?;
.unwrap() drop(stdin);
.write_all(content.as_bytes())
.await?;
let output = child.output().await?.stdout; let output = child.output().await?.stdout;
let sha = String::from_utf8(output)?; let sha = str::from_utf8(&output)?.trim();
log::debug!("indexing SHA: {sha}, path {path:?}"); log::debug!("indexing SHA: {sha}, path {path:?}");
@ -871,6 +869,7 @@ impl GitRepository for RealGitRepository {
String::from_utf8_lossy(&output.stderr) String::from_utf8_lossy(&output.stderr)
); );
} else { } else {
log::debug!("removing path {path:?} from the index");
let output = new_smol_command(&git_binary_path) let output = new_smol_command(&git_binary_path)
.current_dir(&working_directory) .current_dir(&working_directory)
.envs(env.iter()) .envs(env.iter())
@ -921,6 +920,7 @@ impl GitRepository for RealGitRepository {
for rev in &revs { for rev in &revs {
write!(&mut stdin, "{rev}\n")?; write!(&mut stdin, "{rev}\n")?;
} }
stdin.flush()?;
drop(stdin); drop(stdin);
let output = process.wait_with_output()?; let output = process.wait_with_output()?;