fix(sync): filter git-status fast path through ignore matcher#922
fix(sync): filter git-status fast path through ignore matcher#922itxaiohanglover wants to merge 1 commit into
Conversation
The incremental sync's git fast path consumed `git status --porcelain` output without filtering through `buildDefaultIgnore`, so tracked files in default-ignored dirs (node_modules/, vendor/, etc.) leaked back into the index on every sync — disagreeing with a full `index --force`. Build the matcher once and skip ignored paths in the modified+added loop. Deleted files stay unfiltered (removal is always correct for stale entries). Closes colbymchenry#766
psandeep02
left a comment
There was a problem hiding this comment.
The added code appears to:
Create an ignore matcher:
TypeScript
const ig = buildDefaultIgnore(this.rootDir);
Loop through modified and added Git files:
TypeScript
for (const filePath of [...gitChanges.modified, ...gitChanges.added]) {
Skip files that match .gitignore or default ignore patterns:
TypeScript
if (ig.ignores(filePath)) continue;
Why this is useful
The comments explain the intent clearly:
Prevent tracked files inside ignored directories (such as vendor/) from being indexed.
Ensure behavior matches the same ignore rules used elsewhere (getGitVisibleFiles).
Avoid indexing files that Git reports as changed but should be ignored.
Positive points
✅ Good explanatory comments.
✅ Reuses existing ignore logic instead of creating new rules.
✅ Helps maintain consistency between file discovery and indexing.
✅ Likely fixes the issue mentioned (#766) by preventing ignored files from leaking into the index.
Things to verify
Files ignored by .gitignore
Tracked files inside ignored folders
Modified files not ignored
Added files not ignored
Overall Review
Rating: 8.5/10
The change is clean, readable, and appears to solve a real edge case while keeping behavior consistent with Git visibility rules. The comments are especially helpful for future maintainers.
What
Fixes #766
The incremental sync's git fast path consumed
git status --porcelainoutput without filtering throughbuildDefaultIgnore, so tracked files in default-ignored dirs (node_modules/,vendor/, etc.) leaked back into the index on every sync — disagreeing with a fullindex --force.The fix
Build the shared
buildDefaultIgnore(this.rootDir)matcher once andcontinuepast ignored paths in the modified+added loop. Deleted files stay unfiltered — removal is always correct for stale entries, and it lets a newly-excluded dir's old entries clean up.Same approach suggested by @monochrome3694 in the issue, verified locally on a ~1,100-file workspace.
Testing
.tsfile insidenode_modules/, modifies it, and verifiessync()does not index it (filesAdded: 0, filesModified: 0).tsc --noEmitclean.