@@ -109,23 +109,21 @@ fn exe_info() -> Option<BString> {
109
109
fn git_cmd ( executable : PathBuf ) -> Command {
110
110
let mut cmd = Command :: new ( executable) ;
111
111
112
- #[ cfg( windows) ]
113
- {
114
- use std:: env;
112
+ if cfg ! ( windows) {
115
113
use std:: os:: windows:: process:: CommandExt ;
116
114
const CREATE_NO_WINDOW : u32 = 0x08000000 ;
117
115
cmd. creation_flags ( CREATE_NO_WINDOW ) ;
118
116
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 ( "/" ) ;
126
126
}
127
- #[ cfg( not( windows) ) ]
128
- cmd. current_dir ( "/" ) ;
129
127
130
128
// Git 2.8.0 and higher support --show-origin. The -l, -z, and --name-only options were
131
129
// 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 {
140
138
//
141
139
cmd. args ( [ "config" , "-lz" , "--show-origin" , "--name-only" ] )
142
140
. 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 .
144
142
. stdin ( Stdio :: null ( ) )
145
143
. stderr ( Stdio :: null ( ) ) ;
146
144
0 commit comments