Skip to content

Commit 087594c

Browse files
committed
Don't show console on Windows
When used inside GUI application, gix causes console window to appear temporarily, due to execution of git. Command needs special flags to prevent that. More details: https://stackoverflow.com/a/60958956
1 parent 0e8508a commit 087594c

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

gix-path/src/env/git/mod.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,12 @@ pub(super) static EXE_NAME: &str = "git";
8282
pub(super) static EXE_INFO: Lazy<Option<BString>> = Lazy::new(|| {
8383
let git_cmd = |executable: PathBuf| {
8484
let mut cmd = Command::new(executable);
85+
#[cfg(windows)]
86+
{
87+
use std::os::windows::process::CommandExt;
88+
const CREATE_NO_WINDOW: u32 = 0x08000000;
89+
cmd.creation_flags(CREATE_NO_WINDOW);
90+
}
8591
cmd.args(["config", "-l", "--show-origin"])
8692
.stdin(Stdio::null())
8793
.stderr(Stdio::null());

gix-path/src/env/mod.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,12 @@ pub fn system_prefix() -> Option<&'static Path> {
109109
}
110110

111111
let mut cmd = std::process::Command::new(exe_invocation());
112+
#[cfg(windows)]
113+
{
114+
use std::os::windows::process::CommandExt;
115+
const CREATE_NO_WINDOW: u32 = 0x08000000;
116+
cmd.creation_flags(CREATE_NO_WINDOW);
117+
}
112118
cmd.arg("--exec-path").stderr(std::process::Stdio::null());
113119
gix_trace::debug!(cmd = ?cmd, "invoking git to get system prefix/exec path");
114120
let path = cmd.output().ok()?.stdout;

0 commit comments

Comments
 (0)