Skip to content

Honor the VCS ignores in the watch-driven cache updates - #2139

Merged
bbatsov merged 2 commits into
masterfrom
feature/watch-vcs-ignores
Jul 28, 2026
Merged

Honor the VCS ignores in the watch-driven cache updates#2139
bbatsov merged 2 commits into
masterfrom
feature/watch-vcs-ignores

Conversation

@bbatsov

@bbatsov bbatsov commented Jul 28, 2026

Copy link
Copy Markdown
Owner

The last place a .gitignore was going unread. #2126 closed it for files opened
by hand, where one git check-ignore per file is affordable. The watch path
can't do that - projectile--watch-adopt-directory enumerates a whole directory
that was moved into the project, so a process per file was never an option - and
the hole stayed open with a caveat in the docs.

Batching is the answer, and where to batch turned out to be the interesting
part. A pre-pass over the queued events would miss everything found by directory
adoption, since those paths don't exist until the events are applied. So the
handlers record what they added into a batch-scoped list instead, and one
check-ignore --stdin at the end of the debounce window filters the lot. One
process per 0.5s batch, no matter how many files.

Details worth knowing:

  • check-ignore exits 1 when nothing matched. That's an answer, not a failure -
    reading it as one would have quietly made this a no-op, so there's a spec for
    the all-clear case.
  • Only git is asked; any other VCS declines without spawning anything.
  • native indexing is left alone, since it lists ignored files anyway - same
    call as in Don't cache an opened file the VCS ignores #2126.
  • call-process-region rather than a TRAMP-aware call, because watches are
    never armed for a remote project in the first place.

The integration spec creates a real repository with a .gitignore, writes two
files behind Emacs's back, and waits for the notification: the tracked one lands
in the cache and the ignored one doesn't.

That also lets the caveat come out of the manual and be replaced with what
actually happens.

bbatsov added 2 commits July 28, 2026 15:05
The last place a .gitignore was going unread. #2126 fixed it for files
opened by hand, where one check-ignore per file is affordable; the watch
path can be handed a whole directory that was moved in, so a process per
file was not an option and the hole stayed open with a caveat in the
docs.

The batch is the answer: the handlers record what they added, and one
check-ignore at the end of the debounce window filters the lot. That
covers files discovered by directory adoption as well, which a pre-pass
over the queued events would have missed.

Exit status 1 from check-ignore means nothing matched, which is an
answer rather than a failure - reading it as one would have made the
whole thing a no-op.
It created the ignored file in a directory no watch covered, so whether
an event fired for it at all was down to the backend - and on the Emacs
snapshot build the whole cache had been invalidated by then, leaving
nothing to assert against.

Both files now land in the one directory the initial cache causes to be
watched, distinguished by an ignored pattern rather than an ignored
directory. The assertions are also skipped outright when the watch was
dropped, which invalidates the cache and is not this spec's business.
@bbatsov
bbatsov merged commit 34dfd73 into master Jul 28, 2026
10 checks passed
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.

1 participant