From c595a7576d5002bdeede53537f0e3d5d26b87a95 Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Wed, 6 Aug 2025 17:30:36 -0700 Subject: [PATCH] Fix git hunk staging on windows (#35755) We were failing to flush the Git process's `stdin` before dropping it. Release Notes: - N/A --- crates/git/src/repository.rs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/crates/git/src/repository.rs b/crates/git/src/repository.rs index b536bed710..dc7ab0af65 100644 --- a/crates/git/src/repository.rs +++ b/crates/git/src/repository.rs @@ -846,14 +846,12 @@ impl GitRepository for RealGitRepository { .stdin(Stdio::piped()) .stdout(Stdio::piped()) .spawn()?; - child - .stdin - .take() - .unwrap() - .write_all(content.as_bytes()) - .await?; + let mut stdin = child.stdin.take().unwrap(); + stdin.write_all(content.as_bytes()).await?; + stdin.flush().await?; + drop(stdin); 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:?}"); @@ -871,6 +869,7 @@ impl GitRepository for RealGitRepository { String::from_utf8_lossy(&output.stderr) ); } else { + log::debug!("removing path {path:?} from the index"); let output = new_smol_command(&git_binary_path) .current_dir(&working_directory) .envs(env.iter()) @@ -921,6 +920,7 @@ impl GitRepository for RealGitRepository { for rev in &revs { write!(&mut stdin, "{rev}\n")?; } + stdin.flush()?; drop(stdin); let output = process.wait_with_output()?;