Skip to content

Commit e8ec19e

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 cfe2cd3 commit e8ec19e

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/cred.rs

+12
Original file line numberDiff line numberDiff line change
@@ -372,6 +372,12 @@ impl CredentialHelper {
372372
// If that fails then it's up to the user to put `sh` in path and make
373373
// sure it works.
374374
let mut c = Command::new("sh");
375+
#[cfg(windows)]
376+
{
377+
use std::os::windows::process::CommandExt;
378+
const CREATE_NO_WINDOW: u32 = 0x08000000;
379+
c.creation_flags(CREATE_NO_WINDOW);
380+
}
375381
c.arg("-c")
376382
.arg(&format!("{} get", cmd))
377383
.stdin(Stdio::piped())
@@ -384,6 +390,12 @@ impl CredentialHelper {
384390
debug!("`sh` failed to spawn: {}", e);
385391
let mut parts = cmd.split_whitespace();
386392
let mut c = Command::new(parts.next().unwrap());
393+
#[cfg(windows)]
394+
{
395+
use std::os::windows::process::CommandExt;
396+
const CREATE_NO_WINDOW: u32 = 0x08000000;
397+
c.creation_flags(CREATE_NO_WINDOW);
398+
}
387399
for arg in parts {
388400
c.arg(arg);
389401
}

0 commit comments

Comments
 (0)