+ Make clear that `SystemRoot` really is intended to give this, as readers unfamiliar with that variable may erroneously confuse it with `SystemDrive` or otherwise assume it would give a path like `C:\` rather than `C:\Windows`.
Unified · Split
| @@ -118,8 +118,8 @@ fn git_cmd(executable: PathBuf) -> Command { · 117 unmodified lines | ||
| 118 | 118 | // We will try to run `git` from a location fairly high in the filesystem. This can be faster |
| 119 | 119 | // than running it from our own CWD, if we are deeply nested or on network storage. |
| 120 | 120 | let cwd = if cfg!(windows) { |
| 121 | − // Use the Windows directory (usually `C:\Windows`) if we can tell what it is. Don't use | |
| 122 | − // `C:\`, as limited users can put a `.git` dir there (though up-to-date Git won't use it). | |
| 121 | + // Try the Windows directory (usually `C:\Windows`) first. It is given by `SystemRoot`, | |
| 122 | + // except in rare cases where our own parent has not passed down that environment variable. | |
| 123 | 123 | env::var_os("SystemRoot") |
| 124 | 124 | .or_else(|| env::var_os("windir")) |
| 125 | 125 | .map(PathBuf::from) |