gitutil: fix HOME=NUL failure on Windows ARM64#6734
Open
rzlink wants to merge 1 commit intomoby:masterfrom
Open
gitutil: fix HOME=NUL failure on Windows ARM64#6734rzlink wants to merge 1 commit intomoby:masterfrom
rzlink wants to merge 1 commit intomoby:masterfrom
Conversation
On Windows ARM64, git cannot use the NUL device as HOME or GIT_CONFIG_GLOBAL path, failing with "fatal: unable to access 'NUL': Invalid argument". This was introduced by e6e6026 (PR moby#6639) which changed HOME=/dev/null to HOME=os.DevNull. Add platform-specific helpers: on Unix, continue using /dev/null; on Windows, lazily create an empty temp directory for HOME and an empty temp file for GIT_CONFIG_GLOBAL. Signed-off-by: Dawei Wei <wei.dawei.cn@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
PR #6639 (commit e6e6026) changed
HOME=/dev/nulltoHOME=os.DevNullfor cross-platformcompatibility. On Windows,
os.DevNullresolves toNUL. While this works on Windows AMD64,Git on Windows ARM64 cannot use
NULas a HOME directory path:Git attempts to access
NUL/.gitconfig, which fails on ARM64 Windows.Fix
Add platform-specific helpers (
noConfigHome()/noConfigGlobal()):git_noconfig_unix.go): continues using/dev/null(unchanged behavior)git_noconfig_windows.go): lazily creates an empty temp directory for HOME(so
~/.gitconfigis absent) and an empty temp file forGIT_CONFIG_GLOBAL(a validempty gitconfig). Uses
sync.Onceto create these once per process.Falls back to
os.DevNullif temp creation fails, maintaining compatibility on AMD64.Testing
TestGitCLIConfigEnvtests updated to use the new helpers