修复windows下执行部分git命令没有带上CREATE_NO_WINDOW标识
This commit is contained in:
@@ -3,7 +3,7 @@ use std::fs::{File, OpenOptions};
|
|||||||
use std::hash::{Hash, Hasher};
|
use std::hash::{Hash, Hasher};
|
||||||
use std::io::Write;
|
use std::io::Write;
|
||||||
use std::path::{Component, Path, PathBuf};
|
use std::path::{Component, Path, PathBuf};
|
||||||
use std::process::{Command, Stdio};
|
use std::process::Stdio;
|
||||||
use std::sync::{mpsc, LazyLock, Mutex};
|
use std::sync::{mpsc, LazyLock, Mutex};
|
||||||
use std::time::{Duration, Instant, UNIX_EPOCH};
|
use std::time::{Duration, Instant, UNIX_EPOCH};
|
||||||
|
|
||||||
@@ -1883,7 +1883,7 @@ fn git_check_ignored_paths(
|
|||||||
return Ok(HashSet::new());
|
return Ok(HashSet::new());
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut child = Command::new("git")
|
let mut child = crate::process::std_command("git")
|
||||||
.args(["check-ignore", "--stdin", "-z"])
|
.args(["check-ignore", "--stdin", "-z"])
|
||||||
.current_dir(repo_path)
|
.current_dir(repo_path)
|
||||||
.stdin(Stdio::piped())
|
.stdin(Stdio::piped())
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
use std::ffi::{OsStr, OsString};
|
use std::ffi::{OsStr, OsString};
|
||||||
|
use std::process::Command;
|
||||||
|
|
||||||
#[cfg(windows)]
|
#[cfg(windows)]
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
@@ -6,6 +7,25 @@ use std::path::Path;
|
|||||||
#[cfg(windows)]
|
#[cfg(windows)]
|
||||||
const CREATE_NO_WINDOW: u32 = 0x0800_0000;
|
const CREATE_NO_WINDOW: u32 = 0x0800_0000;
|
||||||
|
|
||||||
|
pub fn configure_std_command(command: &mut Command) -> &mut Command {
|
||||||
|
#[cfg(windows)]
|
||||||
|
{
|
||||||
|
use std::os::windows::process::CommandExt;
|
||||||
|
command.creation_flags(CREATE_NO_WINDOW);
|
||||||
|
}
|
||||||
|
|
||||||
|
command
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn std_command<S>(program: S) -> Command
|
||||||
|
where
|
||||||
|
S: AsRef<OsStr>,
|
||||||
|
{
|
||||||
|
let mut command = Command::new(normalized_program(program));
|
||||||
|
configure_std_command(&mut command);
|
||||||
|
command
|
||||||
|
}
|
||||||
|
|
||||||
pub fn configure_tokio_command(
|
pub fn configure_tokio_command(
|
||||||
command: &mut tokio::process::Command,
|
command: &mut tokio::process::Command,
|
||||||
) -> &mut tokio::process::Command {
|
) -> &mut tokio::process::Command {
|
||||||
|
|||||||
Reference in New Issue
Block a user