Commit b95f433
committed
fix: Use
`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.
Although it's not readily apparent why Git for Windows accepts
`NUL` on some Windows operating systems and/or platforms and not
others, the preferential treatment of `nul` (not extending to
`NUL`) can be seen in a few places in the Git for Windows source
code, including in `mingw_access` (`strcmp` is case-sensitive):
https://github.com/git-for-windows/git/blob/a36f720572491aafc59d63ff926b04d9fa787ec3/compat/mingw.c#L1093
Therefore, this changes `"NUL"` to `"nul"` for the Windows null
device path. This allows some functionality where `git` is invoked
that had been broken on ARM64 Windows systems to start working.
See 7280a2d (GitoxideLabs#1567) and 3cf9fc1 (GitoxideLabs#1570) for further context. Git
for Windows also special-cases the literal path `/dev/null` in
access checks and when opening it for read or write (thought not if
an attempt is made to execute or change directory to it). We
nonetheless change `NUL` to `nul` on Windows, rather than changing
it to `/dev/null` and using that value on all platforms.
The reason is that treating `/dev/null` as the null device on
Windows is specific to Git for Windows. `/dev/null` on Windows
would not be the null device, nor otherwise special, if we open it
ourselves, nor if opened indirectly by other programs that don't
special-case it. The Windows path `/dev/null` is equivalent to the
Windows path `\dev\null`. These are relative paths, resolved as
`X:\dev\null` where `X:` is replaced by the current drive. That is
never what we want when we attempt to use the null device.nul instead of NUL on Windows1 parent 48dfacf commit b95f433
2 files changed
+8
-4
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
84 | 84 | | |
85 | 85 | | |
86 | 86 | | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
87 | 91 | | |
88 | | - | |
| 92 | + | |
89 | 93 | | |
90 | 94 | | |
91 | 95 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
619 | 619 | | |
620 | 620 | | |
621 | 621 | | |
622 | | - | |
| 622 | + | |
623 | 623 | | |
624 | 624 | | |
625 | 625 | | |
| |||
1027 | 1027 | | |
1028 | 1028 | | |
1029 | 1029 | | |
1030 | | - | |
| 1030 | + | |
1031 | 1031 | | |
1032 | 1032 | | |
1033 | 1033 | | |
| |||
1036 | 1036 | | |
1037 | 1037 | | |
1038 | 1038 | | |
1039 | | - | |
| 1039 | + | |
1040 | 1040 | | |
1041 | 1041 | | |
1042 | 1042 | | |
| |||
0 commit comments