|
11 | 11 | use std::{
|
12 | 12 | collections::BTreeMap,
|
13 | 13 | env,
|
14 |
| - ffi::OsString, |
| 14 | + ffi::{OsStr, OsString}, |
15 | 15 | io::Read,
|
16 | 16 | path::{Path, PathBuf},
|
17 | 17 | str::FromStr,
|
@@ -589,11 +589,14 @@ const NULL_DEVICE: &str = "NUL";
|
589 | 589 | #[cfg(not(windows))]
|
590 | 590 | const NULL_DEVICE: &str = "/dev/null";
|
591 | 591 |
|
592 |
| -fn configure_command<'a>( |
| 592 | +fn configure_command<'a, I: IntoIterator<Item = S>, S: AsRef<OsStr>>( |
593 | 593 | cmd: &'a mut std::process::Command,
|
594 |
| - args: &[String], |
| 594 | + args: I, |
595 | 595 | script_result_directory: &Path,
|
596 | 596 | ) -> &'a mut std::process::Command {
|
| 597 | + // For simplicity, we extend the `MSYS` variable from from our own environment. This disregards |
| 598 | + // state from any prior `cmd.env("MSYS")` or `cmd.env_remove("MSYS")` calls. Such calls should |
| 599 | + // either be avoided, or made after this function returns (but before spawning the command). |
597 | 600 | let mut msys_for_git_bash_on_windows = env::var_os("MSYS").unwrap_or_default();
|
598 | 601 | msys_for_git_bash_on_windows.push(" winsymlinks:nativestrict");
|
599 | 602 | cmd.args(args)
|
@@ -925,10 +928,9 @@ mod tests {
|
925 | 928 | populate_ad_hoc_config_files(temp.path());
|
926 | 929 |
|
927 | 930 | let mut cmd = std::process::Command::new("git");
|
928 |
| - let args = ["config", "-l", "--show-origin"].map(String::from); |
929 | 931 | cmd.env("GIT_CONFIG_SYSTEM", SCOPE_ENV_VALUE);
|
930 | 932 | cmd.env("GIT_CONFIG_GLOBAL", SCOPE_ENV_VALUE);
|
931 |
| - configure_command(&mut cmd, &args, temp.path()); |
| 933 | + configure_command(&mut cmd, ["config", "-l", "--show-origin"], temp.path()); |
932 | 934 |
|
933 | 935 | let output = cmd.output().expect("can run git");
|
934 | 936 | let lines: Vec<_> = output
|
|
0 commit comments