gitutil: avoid global git config lookup on Windows#6639
gitutil: avoid global git config lookup on Windows#6639crazy-max merged 1 commit intomoby:masterfrom
Conversation
| "HOME=/dev/null", // Disable reading from user gitconfig. | ||
| "LC_ALL=C", // Ensure consistent output. | ||
| } | ||
| if runtime.GOOS == "windows" { |
There was a problem hiding this comment.
It is possible that this works with just GIT_CONFIG_GLOBAL=os.DevNull but I have no way to verify.
There was a problem hiding this comment.
I tested on a Windows host with Git for Windows (git 2.46.0.windows.1), and the fix direction looks right. HOME=/dev/null still breaks there, while HOME=NUL plus an explicit GIT_CONFIG_GLOBAL avoids the global config lookup failure.
And the temp file doesn't seem necessary. GIT_CONFIG_GLOBAL= + os.DevNull also appears to work on Windows in my local probes, so GIT_CONFIG_GLOBAL=os.DevNull may be enough and would avoid creating and cleaning up a temp file for every git invocation.
There was a problem hiding this comment.
Also not directly related but I have this PR to support git host config: #6624
There was a problem hiding this comment.
Given that, I removed the whole windows specific condition and just set GIT_CONFIG_GLOBAL everywhere.
Avoid global conf lookup via HOME that fails on Windows. Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
37338e6 to
e6e6026
Compare
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: rzlink <nicklin@microsoft.com> Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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: rzlink <nicklin@microsoft.com> Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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: rzlink <nicklin@microsoft.com> Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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: rzlink <nicklin@microsoft.com> Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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: rzlink <nicklin@microsoft.com> Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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>
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: rzlink <nicklin@microsoft.com> Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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: rzlink <nicklin@microsoft.com> Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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: rzlink <nicklin@microsoft.com> Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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: rzlink <nicklin@microsoft.com> Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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: rzlink <nicklin@microsoft.com> Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
fix #6567
Use a Windows-specific empty temp file for GIT_CONFIG_GLOBAL while keeping the existing null-device HOME behavior on non-Windows. Preserve the current SSH command handling and add focused gitutil coverage for the config-path behavior.