@@ -109,23 +109,21 @@ fn exe_info() -> Option<BString> {
109109fn git_cmd ( executable : PathBuf ) -> Command {
110110 let mut cmd = Command :: new ( executable) ;
111111
112- #[ cfg( windows) ]
113- {
114- use std:: env;
112+ if cfg ! ( windows) {
115113 use std:: os:: windows:: process:: CommandExt ;
116114 const CREATE_NO_WINDOW : u32 = 0x08000000 ;
117115 cmd. creation_flags ( CREATE_NO_WINDOW ) ;
118116
119- cmd. current_dir (
120- env:: var_os ( "SystemRoot" ) // Most reliable env var for path to Windows directory.
121- . or_else ( || env:: var_os ( "windir" ) ) // Less reliable, but some callers are unusual.
122- . map ( PathBuf :: from)
123- . filter ( |p| p. is_absolute ( ) )
124- . unwrap_or_else ( env:: temp_dir) ,
125- ) ;
117+ use std:: env;
118+ let cwd = env:: var_os ( "SystemRoot" ) // Usually `C:\Windows`. Not to be confused with `C:\`.
119+ . or_else ( || env:: var_os ( "windir" ) ) // Same. Less reliable, but some callers are unusual.
120+ . map ( PathBuf :: from)
121+ . filter ( |p| p. is_absolute ( ) )
122+ . unwrap_or_else ( env:: temp_dir) ;
123+ cmd. current_dir ( cwd) ;
124+ } else {
125+ cmd. current_dir ( "/" ) ;
126126 }
127- #[ cfg( not( windows) ) ]
128- cmd. current_dir ( "/" ) ;
129127
130128 // Git 2.8.0 and higher support --show-origin. The -l, -z, and --name-only options were
131129 // supported even before that. In contrast, --show-scope was introduced later, in Git 2.26.0.
@@ -140,7 +138,7 @@ fn git_cmd(executable: PathBuf) -> Command {
140138 //
141139 cmd. args ( [ "config" , "-lz" , "--show-origin" , "--name-only" ] )
142140 . env ( "GIT_DIR" , NULL_DEVICE ) // Avoid getting local-scope config.
143- . env ( "GIT_WORK_TREE" , NULL_DEVICE ) // Not needed, but clarifies intent .
141+ . env ( "GIT_WORK_TREE" , NULL_DEVICE ) // Just to avoid confusion when debugging .
144142 . stdin ( Stdio :: null ( ) )
145143 . stderr ( Stdio :: null ( ) ) ;
146144
0 commit comments