Skip to content

Commit 3efbeac

Browse files
committed
simplify stdin
1 parent a75ae8f commit 3efbeac

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

git2-hooks/src/hookspath.rs

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -171,16 +171,20 @@ impl HookPaths {
171171
.args(args)
172172
.current_dir(&self.pwd)
173173
.with_no_window()
174-
.stdin(std::process::Stdio::piped())
174+
.stdin(if stdin.is_some() {
175+
std::process::Stdio::piped()
176+
} else {
177+
std::process::Stdio::null()
178+
})
175179
.stdout(std::process::Stdio::piped())
176180
.stderr(std::process::Stdio::piped())
177181
.spawn()?;
178182

179-
if let Some(mut stdin_handle) = child.stdin.take() {
183+
if let (Some(mut stdin_handle), Some(input)) =
184+
(child.stdin.take(), stdin)
185+
{
180186
use std::io::Write;
181-
if let Some(input) = stdin {
182-
stdin_handle.write_all(input)?;
183-
}
187+
stdin_handle.write_all(input)?;
184188
drop(stdin_handle);
185189
}
186190

0 commit comments

Comments
 (0)