Skip to content

Commit c595a75

Browse files
authored
Fix git hunk staging on windows (#35755)
We were failing to flush the Git process's `stdin` before dropping it. Release Notes: - N/A
1 parent 8e290b4 commit c595a75

1 file changed

Lines changed: 7 additions & 7 deletions

File tree

crates/git/src/repository.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -846,14 +846,12 @@ impl GitRepository for RealGitRepository {
846846
.stdin(Stdio::piped())
847847
.stdout(Stdio::piped())
848848
.spawn()?;
849-
child
850-
.stdin
851-
.take()
852-
.unwrap()
853-
.write_all(content.as_bytes())
854-
.await?;
849+
let mut stdin = child.stdin.take().unwrap();
850+
stdin.write_all(content.as_bytes()).await?;
851+
stdin.flush().await?;
852+
drop(stdin);
855853
let output = child.output().await?.stdout;
856-
let sha = String::from_utf8(output)?;
854+
let sha = str::from_utf8(&output)?.trim();
857855

858856
log::debug!("indexing SHA: {sha}, path {path:?}");
859857

@@ -871,6 +869,7 @@ impl GitRepository for RealGitRepository {
871869
String::from_utf8_lossy(&output.stderr)
872870
);
873871
} else {
872+
log::debug!("removing path {path:?} from the index");
874873
let output = new_smol_command(&git_binary_path)
875874
.current_dir(&working_directory)
876875
.envs(env.iter())
@@ -921,6 +920,7 @@ impl GitRepository for RealGitRepository {
921920
for rev in &revs {
922921
write!(&mut stdin, "{rev}\n")?;
923922
}
923+
stdin.flush()?;
924924
drop(stdin);
925925

926926
let output = process.wait_with_output()?;

0 commit comments

Comments
 (0)