fix(snapshot): avoid ENAMETOOLONG error caused by git check-ignore command.#22544
Closed
thisxiangyu wants to merge 1 commit intoanomalyco:devfrom
Closed
fix(snapshot): avoid ENAMETOOLONG error caused by git check-ignore command.#22544thisxiangyu wants to merge 1 commit intoanomalyco:devfrom
thisxiangyu wants to merge 1 commit intoanomalyco:devfrom
Conversation
Contributor
|
Thanks for your contribution! This PR doesn't have a linked issue. All PRs must reference an existing issue. Please:
See CONTRIBUTING.md for details. |
Author
|
b775459 to
a5b2b3f
Compare
…o avoid ENAMETOOLONG error on Windows When a worktree has many ignored files (e.g., 75,000+), calling 'git check-ignore --no-index' with all file paths as command-line arguments exceeds Windows' 32KB limit, causing ENAMETOOLONG errors. This replaces the git check-ignore calls in add(), patch(), and diffFull() functions with the local 'ignore' library (already used in src/file/index.ts), which provides equivalent gitignore pattern matching without command-line length limits. Fixes anomalyco#16336, anomalyco#18072
a5b2b3f to
5c09bd8
Compare
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.
Issue for this PR
Fixes #22538 #22540
Type of change
What does this PR do?
When a worktree has many ignored files (e.g., 75,000+), the snapshot
add()function fails withENAMETOOLONGerror. This happens becausegit check-ignore --no-indexis called with all file paths as command-line arguments, exceeding the 32KB command-line limit.The fix replaces calls to
git check-ignore --no-indexwith localignorelibrary (already used elsewhere in the codebase atsrc/file/index.ts). This library provides equivalent gitignore pattern matching without command-line length limits.Changes:
parseIgnore()helper inpackages/opencode/src/snapshot/index.tsto load.gitignoreand.ignorefilesadd(),patch(), anddiffFull()functions to filter ignored files locally instead of spawning git process/suffix) are checked to handle directory rules correctlyHow did you verify your code works?
Tested locally on Windows by:
Checklist