From 5ef0a04ed021c8e07d2bfd1f0a8410cd73ecb32e Mon Sep 17 00:00:00 2001 From: JOJO <1498581755@qq.com> Date: Fri, 31 Jul 2026 18:19:51 +0800 Subject: [PATCH] =?UTF-8?q?fix(windows):=20=E6=B2=99=E7=AE=B1=E5=8F=91?= =?UTF-8?q?=E8=A1=8C=E7=89=88=20git=20=E5=A2=9E=E5=8A=A0=20autocrlf/checkS?= =?UTF-8?q?tat/trustctime=20=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/setup-wsl-sandbox.ps1 | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/scripts/setup-wsl-sandbox.ps1 b/scripts/setup-wsl-sandbox.ps1 index aa2bc65e..c6db9c7f 100644 --- a/scripts/setup-wsl-sandbox.ps1 +++ b/scripts/setup-wsl-sandbox.ps1 @@ -68,6 +68,15 @@ Write-Host "==> [6/6] 安装沙箱工具链(bubblewrap / bash / python3 / git $apk = Invoke-Wsl -d $DistroName -- sh -c "apk update && apk add bubblewrap bash ncurses-libs python3 git" if ($apk.Code -ne 0) { throw "apk 安装失败: $($apk.Output)" } +# 与 Windows 端 Git for Windows 默认的 core.autocrlf=true 对齐: +# Windows 检出的工作区文件是 CRLF,沙箱 git 不开 autocrlf 会把全部文件误判为已修改 +# (全量 +/-),且全量内容读取+xdiff 会让 git 命令慢到触发执行超时。 +$null = Invoke-Wsl -d $DistroName -e git config --system core.autocrlf true +# 9P 挂载的 inode/ctime 语义与 Windows git 写入的索引不匹配,会导致沙箱 git 对全部 +# 文件做内容重读(全树 status/diff >20s);放宽 stat 校验后只需秒级。 +$null = Invoke-Wsl -d $DistroName -e git config --system core.checkStat minimal +$null = Invoke-Wsl -d $DistroName -e git config --system core.trustctime false + # 验收 $verify = Invoke-Wsl -d $DistroName -- sh -c "bwrap --version && bash -c 'echo bash-ok' && python3 --version && git --version" Write-Host $verify.Output