Skip to content

Commit 393d900

Browse files
committed
fix: Use nul instead of NUL on Windows
`NULL_DEVICE` is `/dev/null` except on Windows, where there are several possible choices. Previously we were using `NUL` because the more modern full path `\\.\NUL` is not supported by `git`. However, `git` also rejects `NUL`, when capitalized, on some Windows systems. This can be observed on Windows 11 ARM64 builds. In contrast, the lower-case `nul`, which Windows itself treats the same as `NUL`, is always accepted by Git for Windows. This change allows some broken functionality to work on ARM64 Windows systems.
1 parent 115695e commit 393d900

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

gix-path/src/env/git/mod.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,11 @@ pub(super) const EXE_NAME: &str = "git";
8484
/// The git executable is the one found in PATH or an alternative location.
8585
pub(super) static GIT_HIGHEST_SCOPE_CONFIG_PATH: Lazy<Option<BString>> = Lazy::new(exe_info);
8686

87+
// There are a number of ways to refer to the null device on Windows, but they are not all equally
88+
// well supported. Git for Windows rejects `\\.\NUL` and `\\.\nul`, and on some system, even the
89+
// legacy name `NUL`, when capitalized. But Git for Widnows always accepts the lower-case `nul`.
8790
#[cfg(windows)]
88-
const NULL_DEVICE: &str = "NUL";
91+
const NULL_DEVICE: &str = "nul";
8992
#[cfg(not(windows))]
9093
const NULL_DEVICE: &str = "/dev/null";
9194

tests/tools/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -619,7 +619,7 @@ fn scripted_fixture_read_only_with_args_inner(
619619
}
620620

621621
#[cfg(windows)]
622-
const NULL_DEVICE: &str = "NUL";
622+
const NULL_DEVICE: &str = "nul"; // See `gix_path::env::git::NULL_DEVICE` on why this form is used.
623623
#[cfg(not(windows))]
624624
const NULL_DEVICE: &str = "/dev/null";
625625

0 commit comments

Comments
 (0)