diff --git a/refs/update_refs.rs b/refs/update_refs.rs index e65ee71..7de7ad8 100644 --- a/refs/update_refs.rs +++ b/refs/update_refs.rs @@ -26,7 +26,7 @@ impl GitBare { return Ok(UpdateReferencesResponse::default()); } - let output = std::process::Command::new("git") + let mut child = std::process::Command::new("git") .args([ "--git-dir", &self.bare_dir.to_string_lossy(), @@ -37,12 +37,29 @@ impl GitBare { .stdin(std::process::Stdio::piped()) .stdout(std::process::Stdio::piped()) .stderr(std::process::Stdio::piped()) - .output() + .spawn() .map_err(|e| crate::error::GitError::CommandFailed { status_code: None, stderr: e.to_string(), })?; + if let Some(ref mut stdin) = child.stdin { + use std::io::Write; + stdin.write_all(stdin_input.as_bytes()).map_err(|e| { + crate::error::GitError::CommandFailed { + status_code: None, + stderr: format!("failed to write stdin: {e}"), + } + })?; + } + drop(child.stdin.take()); + let output = child.wait_with_output().map_err(|e| { + crate::error::GitError::CommandFailed { + status_code: None, + stderr: e.to_string(), + } + })?; + let stderr = String::from_utf8_lossy(&output.stderr).into_owned(); if !output.status.success() { return Ok(UpdateReferencesResponse {