This uses the null device, `/dev/null` on Unix-like systems and `NUL` on Windows, as the value of `GIT_CONFIG_SYSTEM` and `GIT_CONFIG_GLOBAL` when `gix-testtols` runs test fixture shell scripts. `/dev/null` is explicitly recommended for this purpose, when setting those environment variables for the purpose of preventing configuration files from being read, in the Git documentation: - https://git-scm.com/docs/git#Documentation/git.txt-codeGITCONFIGGLOBALcode On Windows, `NUL` is an analogue of `/dev/null`. Even in the unusual scenario that a `\\?\` prefixed UNC path is used to create an actual file named `NUL` in the directory the fixture script operates in, the relative path `NUL` still resolves to the null device and not to that file. The previous behavior was to use a value of `:` on Unix-like systems or `-` on Windows. But these were really just unusual but valid paths, such that files of those names could exist in any location. `git` furthermore treats them as paths: a `:` is not special in these environment variables because they hold a single path rather than a list of paths, and a `-` is not special (for example, it does not specify stdin) because it appears in an environment variable rather than a command-line argument. While `:` and `-` are unusual filenames, this code is used in testing, including of edge cases where unusual files may be used. So this change may make the test tools slightly more robust.
Unified · Split
| @@ -583,12 +583,16 @@ fn scripted_fixture_read_only_with_args_inner( · 582 unmodified lines | |||
| 583 | Ok(script_result_directory) | 583 | Ok(script_result_directory) |
| 584 | } | 584 | } |
| 585 | 585 | ||
| 586 | #[cfg(windows)] | ||
| 587 | const NULL_DEVICE: &str = "NUL"; | ||
| 588 | #[cfg(not(windows))] | ||
| 589 | const NULL_DEVICE: &str = "/dev/null"; | ||
| 590 | |||
| 586 | fn configure_command<'a>( | 591 | fn configure_command<'a>( |
| 587 | cmd: &'a mut std::process::Command, | 592 | cmd: &'a mut std::process::Command, |
| 588 | args: &[String], | 593 | args: &[String], |
| 589 | script_result_directory: &Path, | 594 | script_result_directory: &Path, |
| 590 | ) -> &'a mut std::process::Command { | 595 | ) -> &'a mut std::process::Command { |
| 591 | let never_path = if cfg!(windows) { "-" } else { ":" }; | ||
| 592 | let mut msys_for_git_bash_on_windows = std::env::var("MSYS").unwrap_or_default(); | 596 | let mut msys_for_git_bash_on_windows = std::env::var("MSYS").unwrap_or_default(); |
| 593 | msys_for_git_bash_on_windows.push_str(" winsymlinks:nativestrict"); | 597 | msys_for_git_bash_on_windows.push_str(" winsymlinks:nativestrict"); |
| 594 | cmd.args(args) | 598 | cmd.args(args) |
| @@ -599,8 +603,8 @@ fn configure_command<'a>( · 4 unmodified lines | |||
| 599 | .env_remove("GIT_ASKPASS") | 603 | .env_remove("GIT_ASKPASS") |
| 600 | .env_remove("SSH_ASKPASS") | 604 | .env_remove("SSH_ASKPASS") |
| 601 | .env("MSYS", msys_for_git_bash_on_windows) | 605 | .env("MSYS", msys_for_git_bash_on_windows) |
| 602 | .env("GIT_CONFIG_SYSTEM", never_path) | 606 | .env("GIT_CONFIG_SYSTEM", NULL_DEVICE) |
| 603 | .env("GIT_CONFIG_GLOBAL", never_path) | 607 | .env("GIT_CONFIG_GLOBAL", NULL_DEVICE) |
| 604 | .env("GIT_TERMINAL_PROMPT", "false") | 608 | .env("GIT_TERMINAL_PROMPT", "false") |
| 605 | .env("GIT_AUTHOR_DATE", "2000-01-01 00:00:00 +0000") | 609 | .env("GIT_AUTHOR_DATE", "2000-01-01 00:00:00 +0000") |
| 606 | .env("GIT_AUTHOR_EMAIL", "author@example.com") | 610 | .env("GIT_AUTHOR_EMAIL", "author@example.com") |