fix: use env vars for git windows.appendAtomically on Windows
The previous fix set git config --global before clone, but on systems where atomic writes are broken (OneDrive, antivirus, NTFS filter drivers), even writing ~/.gitconfig fails with 'Invalid argument'. Fix: inject the config via GIT_CONFIG_COUNT/KEY/VALUE environment variables, which git reads before performing any file I/O. This bypasses the chicken-and-egg problem where git can't write the config file that would fix its file-writing issue.
This commit is contained in:
@@ -427,10 +427,17 @@ function Install-Repository {
|
||||
}
|
||||
} else {
|
||||
# Fix Windows git "copy-fd: write returned: Invalid argument" error.
|
||||
# Must be set BEFORE clone, otherwise git fails copying hook templates.
|
||||
# Also fixes "unable to write loose object file" for later operations.
|
||||
# Git for Windows can fail on atomic file operations (hook templates,
|
||||
# config lock files) due to antivirus, OneDrive, or NTFS filter drivers.
|
||||
# Setting windows.appendAtomically=false via ENVIRONMENT bypasses the
|
||||
# issue entirely — git reads these before touching any files, unlike
|
||||
# --global config which itself may fail to write.
|
||||
Write-Info "Configuring git for Windows compatibility..."
|
||||
git config --global windows.appendAtomically false
|
||||
$env:GIT_CONFIG_COUNT = "1"
|
||||
$env:GIT_CONFIG_KEY_0 = "windows.appendAtomically"
|
||||
$env:GIT_CONFIG_VALUE_0 = "false"
|
||||
# Also try global config (may fail but harmless)
|
||||
git config --global windows.appendAtomically false 2>$null
|
||||
|
||||
# Try SSH first (for private repo access), fall back to HTTPS.
|
||||
# GIT_SSH_COMMAND with BatchMode=yes prevents SSH from hanging
|
||||
|
||||
Reference in New Issue
Block a user