Showing the changes to git-command/src (1 of 1 file). Show all
Unified · Split
| @@ -1,4 +1,4 @@ | ||
| 1 | −//! Launch commands very similarly to `std::process::Command`, but with `git` specific capabilities and adjustments. | |
| 1 | +//! Launch commands very similarly to `Command`, but with `git` specific capabilities and adjustments. | |
| 2 | 2 | #![deny(rust_2018_idioms, missing_docs)] |
| 3 | 3 | #![forbid(unsafe_code)] |
| 4 | 4 | |
| @@ -15,7 +15,7 @@ pub struct Prepare { · 10 unmodified lines | ||
| 15 | 15 | |
| 16 | 16 | mod prepare { |
| 17 | 17 | use crate::Prepare; |
| 18 | − use std::process::Stdio; | |
| 18 | + use std::process::{Command, Stdio}; | |
| 19 | 19 | |
| 20 | 20 | /// Builder |
| 21 | 21 | impl Prepare { |
| @@ -49,16 +49,23 @@ mod prepare { · 27 unmodified lines | ||
| 49 | 49 | impl Prepare { |
| 50 | 50 | /// Spawn the command as configured. |
| 51 | 51 | pub fn spawn(self) -> std::io::Result<std::process::Child> { |
| 52 | + let mut cmd: Command = self.into(); | |
| 53 | + cmd.spawn() | |
| 54 | + } | |
| 55 | + } | |
| 56 | + | |
| 57 | + impl Into<Command> for Prepare { | |
| 58 | + fn into(self) -> Command { | |
| 52 | 59 | let mut cmd = if self.use_shell { |
| 53 | − let mut cmd = std::process::Command::new(if cfg!(windows) { "sh" } else { "/bin/sh" }); | |
| 60 | + let mut cmd = Command::new(if cfg!(windows) { "sh" } else { "/bin/sh" }); | |
| 54 | 61 | cmd.arg("-c"); |
| 55 | 62 | cmd.arg(self.command); |
| 56 | 63 | cmd |
| 57 | 64 | } else { |
| 58 | − std::process::Command::new(self.command) | |
| 65 | + Command::new(self.command) | |
| 59 | 66 | }; |
| 60 | 67 | cmd.stdin(self.stdin).stdout(self.stdout).stderr(self.stderr); |
| 61 | − cmd.spawn() | |
| 68 | + cmd | |
| 62 | 69 | } |
| 63 | 70 | } |
| 64 | 71 | } |