Skip to content

Respect .gitignore negation patterns during indexing#399

Open
caioribeiroclw-pixel wants to merge 1 commit into
zilliztech:masterfrom
caioribeiroclw-pixel:fix-gitignore-negation-indexing
Open

Respect .gitignore negation patterns during indexing#399
caioribeiroclw-pixel wants to merge 1 commit into
zilliztech:masterfrom
caioribeiroclw-pixel:fix-gitignore-negation-indexing

Conversation

@caioribeiroclw-pixel

Copy link
Copy Markdown

Fixes #397.

This makes file-based ignore matching honor ! negation patterns instead of treating them as inert literal patterns. The bug in #397 can silently remove intentionally tracked/whitelisted directories from the index, which is especially risky for code-search agents because the user sees a completed index but the search universe is incomplete.

What changed:

  • Context.matchesIgnorePattern now evaluates ignore rules in order and lets later !pattern rules re-include matching paths.
  • FileSynchronizer.shouldIgnore uses the same ordered negation behavior so initial indexing and sync hashing stay aligned.
  • Added regression coverage for the reported WordPress-style pattern:
    wp-content/plugins/*
    !wp-content/plugins/app
    !wp-content/plugins/backoffice
    covering both initial indexing and sync hashing.

Validation:

  • git diff --check
  • from packages/core: ./node_modules/.bin/jest src/context.ignore-patterns.test.ts --runInBand
  • from packages/core: ./node_modules/.bin/tsc --noEmit

Note: I intentionally kept this narrow and did not replace the matcher with a full gitignore parser. The goal is to fix the silent exclusion case from #397 without changing unrelated ignore semantics.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: .gitignore negation patterns (!pattern) not supported, causing tracked directories to be silently excluded from index

1 participant