fix(snapshot): complete gitignore respect for previously tracked files#22172
Merged
fix(snapshot): complete gitignore respect for previously tracked files#22172
Conversation
The previous fix (#22171) was incomplete. This adds the missing pieces: 1. --no-index flag to git check-ignore (critical for tracked files) Without --no-index, check-ignore returns exit code 1 for tracked files even if they match gitignore patterns 2. diffFull() filtering - filters gitignored files from diff results when gitignore changes between two track() calls 3. Complete test coverage: - files tracked in snapshot but now gitignored are filtered out - gitignore updated between track calls filters from diff The fix now properly handles the case where a file was: 1. Already in git (committed) 2. Tracked in snapshot 3. Later added to .gitignore Such files will no longer appear in patches or diffs.
Contributor
There was a problem hiding this comment.
Your free trial has ended. If you'd like to continue receiving code reviews, you can add a payment method here.
alexyaroshuk
pushed a commit
to alexyaroshuk/opencode
that referenced
this pull request
Apr 13, 2026
mrsimpson
pushed a commit
to mrsimpson/opencode
that referenced
this pull request
Apr 14, 2026
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.
Summary
The previous fix (#22171) was incomplete. This PR adds the missing critical pieces.
What was missing in #22171
Missing
--no-indexflag ingit check-ignorecommands--no-index,check-ignorereturns exit code 1 for tracked filesa.txt) wouldn't be filtered even if added to.gitignoreMissing
diffFull()filteringtrack()calls,diffFull(from, to)would still show gitignored filesThe Complete Fix
In
add()function:git check-ignore --no-indexto identify newly-ignored filesgit rm --cachedIn
patch()function:--no-indexIn
diffFull()function:Test Coverage
files tracked in snapshot but now gitignored are filtered out
a.txtfrom bootstrap (already committed to git)gitignore updated between track calls filters from diff (NEW)
track()callsdiffFull()resultsWhy
--no-indexis criticalVerification
All 53 snapshot tests pass including 2 new tests.