fix(discover): honor .git/info/exclude during file discovery#493
Open
ShauryaaSharma wants to merge 2 commits into
Open
fix(discover): honor .git/info/exclude during file discovery#493ShauryaaSharma wants to merge 2 commits into
ShauryaaSharma wants to merge 2 commits into
Conversation
index_repository only loaded .gitignore when building the exclusion matcher. .git/info/exclude — the per-clone exclude file that Git treats as authoritative — was never read, so paths excluded only there were walked in full. On repos with Sandcastle worktrees this caused the indexer to traverse 661K files / 170 GB and OOM (issue DeusData#489). Add cbm_gitignore_merge() to append patterns from one matcher into another. In cbm_discover_ex, after loading .gitignore, also load .git/info/exclude and merge its patterns in. If only the exclude file exists, use it directly. No downstream call paths change. Add three unit tests for cbm_gitignore_merge and two integration tests that reproduce the issue scenario (exclude-only and exclude-stacked- with-gitignore). Signed-off-by: ShauryaaSharma <shauryasofficial27@gmail.com>
Signed-off-by: ShauryaaSharma <shauryasofficial27@gmail.com>
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.
Fixes #489
Problem
index_repositoryhonored.gitignorebut silently ignored.git/info/exclude— the per-clone exclude file that Git itself treats as authoritative. Any paths excluded only viainfo/exclude(e.g. Sandcastle worktrees) were walked in full.In the reported case this caused the indexer to traverse 661,430 files / 170 GB of worktree content and OOM.
Solution
Added
cbm_gitignore_merge()to append patterns from one matcher into another. Incbm_discover_ex, after loading.gitignore, the code now also loads.git/info/excludeand merges its patterns in. If only the exclude file exists (no.gitignore), it is used directly. No downstream call paths change.Changes
src/discover/discover.h— declarecbm_gitignore_mergesrc/discover/gitignore.c— implementcbm_gitignore_mergesrc/discover/discover.c— load and merge.git/info/excludeincbm_discover_extests/test_gitignore.c— 3 unit tests forcbm_gitignore_mergetests/test_discover.c— 2 integration tests reproducing the issue scenarioTesting
Added
discover_git_info_excludeanddiscover_git_info_exclude_stacks_with_gitignoreto the discover suite, covering the exact reproduction case from the issue report.