Repository navigation
fix(wsl): bound the line-ending sample's index scan, not just its matches - #29552
Conversation
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 11 minutes. View limit details
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Priority: ➖ Normal Merge Risk: ⚪ Minimal · up to
|
…ches The WSL-on-Windows-drive line-ending sample piped ls-files --eol through grep then head, so when no entry was eligible (* text=auto) head never closed the pipe and every file was read over drvfs until the 15 s timeout, which stage, discard and commit waited on after each backoff. Cap the raw ls-files output before the grep. Follow-up to #27778.
b1b632e to
c2a3c84
Compare
ELI5
When a WSL repo lives on a Windows drive (
/mnt/c/...), Orca peeks at a sample of files to learn whether Windows Git wrote them with Windows line endings. That peek was supposed to look at a couple hundred files, but in some repos it ended up reading every file in the repo over the slow Windows-drive bridge. Stage, discard and commit sat waiting on it. Now the peek stops after a fixed number of files, whatever it finds.What Changed
Before: the sample ran
git ls-files --eol | grep <eligible files> | head -n 200. Theheadonly counts lines that pass the filter. In a repo with* text=autoin.gitattributes, no line passes, soheadnever fills up, never closes the pipe, and git keeps going.ls-files --eolopens each working file to inspect it, so git read the whole repo across the Windows-drive mount until the 15 s timeout. A timeout counts as a failure, so it retried (backing off from 30 s up to 10 min), and every stage, discard or commit with no fresh sample waited about 15 s for the next attempt.After: the script is
git ls-files --eol | head -n 2000 | grep <eligible files> | head -n 200. The firstheadcaps how many index entries git lists, and so how many files it reads, whether or not anything matches. The secondheadstill caps the sample at 200. A repo with nothing eligible now gets a fast "inconclusive" answer instead of a timeout. That answer is cached and falls back toautocrlf=inputexactly as before.Mechanism: once the first
headhas its 2000 lines it exits, and git dies of SIGPIPE on its next write. Git restores the default SIGPIPE handling at startup, so this holds on every git version Orca supports. The real stop point is 2000 entries plus whatever fits in the pipe and stdio buffers, which is still a fixed bound. The new cap isLINE_ENDING_SCAN_LIMIT(10 × the 200-file sample cap). It is passed as$3through the existingrunWslProcessargv path, which usesbuildWslExecArgs/--exec, sowsl.exenever expands$.Why
The audit's suggestion was to cap the raw scan rather than only the matches, and that is what this does. The alternatives were:
2000 entries is 10× the sample size. In a normal repo the 200 eligible files are found well inside it, so the answer is unchanged. Where they aren't, the existing "inconclusive →
autocrlf=input" fallback applies, the same result the timeout path ended in.Git compatibility:
ls-files --eolis Git 2.10+ (baseline 2.25), andhead -nis POSIX.Linked Issue
Follow-up to #27778 (which added the line-ending sample). Found in a post-merge performance audit.
Visual Proof
N/A: no UI change. The effect is that git writes stop stalling on Windows-drive WSL repos with
* text=auto.Testing
Measured on macOS (APFS) with a generated 200,001-file repo using the real script and real git 2.x:
* text=auto(nothing eligible)This was a local disk, not a Windows drive mounted in WSL. There, each file read is far slower, which makes the old unbounded case much worse and the bounded one still capped. I did not have a WSL machine for a drvfs timing.
New
src/main/git/wsl-windows-checkout-sample-script.test.tsruns the exactSAMPLE_SCRIPTunder/bin/shagainst a stand-ingitwhosels-filesnever ends (yes):Skipped on Windows, where there is no
/bin/sh. The probe test now asserts the extra argv value.pnpm tc, the WSL checkout tests, andcheck:code-quality:changedpass.AI Disclosure
Review
An adversarial review found nothing blocking. It confirmed the SIGPIPE stop, the argv and quoting, the exit-code behaviour (no pipefail, so the last
headdecides) and Git 2.25 compatibility. A stale doc comment it flagged is fixed. Noted but unchanged: a repo whose first 2000 entries hold only a handful of eligible files decides on that smaller run. The bias toward the start of the path order was already there, over a wider window.Agent skill upstream boundary
Notes
Ensure no issues in: Security, Cross-platoform support (Linux, Windows, Mac), Remote SSH, Mobile, general backwards compatibility, performance
Only affects WSL git commands whose working directory is on a Windows drive. Native, SSH and plain-WSL repos are untouched.
Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)