@@ -4,16 +4,23 @@ use git2::{self, BranchType, Cred, Oid, RemoteCallbacks, Repository, Sort};
44use std:: collections:: HashMap ;
55use std:: path:: { Path , PathBuf } ;
66use std:: process:: Command ;
7+ #[ cfg( target_os = "windows" ) ]
8+ use std:: os:: windows:: process:: CommandExt ;
79
810use crate :: models:: { BranchInfo , BranchMetadata , Commit , StashEntry } ;
911
1012/// Run a git command in the specified directory and return stdout as a String.
1113/// This is a standalone utility for handlers that don't need a full GitRepository.
1214pub fn run_git ( args : & [ & str ] , repo_path : & Path ) -> Result < String , String > {
13- let output = Command :: new ( "git" )
14- . args ( args)
15- . current_dir ( repo_path)
16- . output ( )
15+ let mut cmd = Command :: new ( "git" ) ;
16+ cmd. args ( args) . current_dir ( repo_path) ;
17+
18+ #[ cfg( target_os = "windows" ) ]
19+ {
20+ cmd. creation_flags ( 0x08000000 ) ; // CREATE_NO_WINDOW
21+ }
22+
23+ let output = cmd. output ( )
1724 . map_err ( |e| e. to_string ( ) ) ?;
1825
1926 if !output. status . success ( ) {
@@ -180,10 +187,15 @@ impl GitRepository {
180187
181188 /// Run a git command in this repository and return stdout as a String.
182189 pub fn run_git ( & self , args : & [ & str ] ) -> Result < String > {
183- let output = Command :: new ( "git" )
184- . args ( args)
185- . current_dir ( & self . path )
186- . output ( )
190+ let mut cmd = Command :: new ( "git" ) ;
191+ cmd. args ( args) . current_dir ( & self . path ) ;
192+
193+ #[ cfg( target_os = "windows" ) ]
194+ {
195+ cmd. creation_flags ( 0x08000000 ) ; // CREATE_NO_WINDOW
196+ }
197+
198+ let output = cmd. output ( )
187199 . with_context ( || format ! ( "Failed to run git with args {:?}" , args) ) ?;
188200
189201 if !output. status . success ( ) {
@@ -196,10 +208,15 @@ impl GitRepository {
196208
197209 /// Run a git command in this repository and return stdout bytes.
198210 pub fn run_git_bytes ( & self , args : & [ & str ] ) -> Result < Vec < u8 > > {
199- let output = Command :: new ( "git" )
200- . args ( args)
201- . current_dir ( & self . path )
202- . output ( )
211+ let mut cmd = Command :: new ( "git" ) ;
212+ cmd. args ( args) . current_dir ( & self . path ) ;
213+
214+ #[ cfg( target_os = "windows" ) ]
215+ {
216+ cmd. creation_flags ( 0x08000000 ) ; // CREATE_NO_WINDOW
217+ }
218+
219+ let output = cmd. output ( )
203220 . with_context ( || format ! ( "Failed to run git with args {:?}" , args) ) ?;
204221
205222 if !output. status . success ( ) {
0 commit comments