From a028e4a03a9010fb19d7520e2cf9cfe5522fbbef Mon Sep 17 00:00:00 2001 From: Fedor Sheremetyev Date: Sat, 8 Mar 2025 10:42:37 +0000 Subject: [PATCH] git: Don't show console on Windows When used inside GUI application, git.subprocess=true option causes console window to appear temporarily. std::process::Command needs special flags to prevent that. More details: https://stackoverflow.com/a/60958956 --- lib/src/git_subprocess.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lib/src/git_subprocess.rs b/lib/src/git_subprocess.rs index 57171a3cd..c463d474b 100644 --- a/lib/src/git_subprocess.rs +++ b/lib/src/git_subprocess.rs @@ -105,6 +105,14 @@ impl<'a> GitSubprocessContext<'a> { /// Create the Git command fn create_command(&self) -> Command { let mut git_cmd = Command::new(self.git_executable_path); + // Hide console window on Windows (https://stackoverflow.com/a/60958956) + #[cfg(windows)] + { + use std::os::windows::process::CommandExt; + const CREATE_NO_WINDOW: u32 = 0x08000000; + git_cmd.creation_flags(CREATE_NO_WINDOW); + } + // TODO: here we are passing the full path to the git_dir, which can lead to UNC // bugs in Windows. The ideal way to do this is to pass the workspace // root to Command::current_dir and then pass a relative path to the git