fix: a single negation (!) in .graphifyignore no longer disables all directory pruning - #1276
Merged
safishamsi merged 1 commit intoJun 12, 2026
Conversation
A single `!` rule in .graphifyignore set a blanket `has_negation` flag that disabled directory-level pruning for EVERY ignored directory during the os.walk in detect(). One unrelated `!docs/**` therefore made the walk descend bin/, obj/, wwwroot/, generated/, … on large repos — a pathological slowdown. Output stayed correct (the per-file `_is_ignored` filter still excluded those files), but the walk visited the entire tree. The bypass was unnecessary: `_is_ignored` already honours negations correctly — last-match-wins lets `!dir/` un-ignore a directory (so it is not pruned), and the gitignore parent-exclusion rule means a `!` cannot rescue a file beneath an excluded directory, so descending an ignored dir to find a re-included file is never needed. Prune purely on `_is_noise_dir` + `_is_ignored`. Adds a regression test that tracks os.walk and asserts the ignored dir is never descended while the negation still re-includes its target. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
safishamsi
added a commit
that referenced
this pull request
Jun 12, 2026
rbelem
pushed a commit
to rbelem/graphify
that referenced
this pull request
Jun 12, 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.
Fixes #1274
Problem
A single
!rule in.graphifyignoreset a blankethas_negationflag(
detect.py:1047) that disabled directory-level pruning for every ignoreddirectory during the
os.walkindetect()(detect.py:1051). One unrelated!docs/**therefore made the walk descendnode_modules/,bin/,obj/,wwwroot/, … on large repos — a major slowdown.Output stayed correct (the per-file
_is_ignoredfilter still excluded thosefiles), so this is a walk-performance bug, not a correctness one — but the
detection pass visited the entire tree unnecessarily.
Fix
Remove the
has_negationbypass and prune purely on_is_noise_dir+_is_ignored. The bypass was unnecessary:_is_ignoredalready honoursnegations correctly —
!dir/un-ignore a directory, so it isn't pruned, and!cannot rescue a file beneath anexcluded directory,
so descending an ignored directory to find a re-included file is never needed.
Test
Adds a regression test that tracks
os.walkand asserts the ignored directoryis never descended while the negation still re-includes its target.