zed/crates/worktree
Cole Miller cd944ad8d6
git: Correctly filter ignored paths inside gitdirs on all platforms (#54548)
Previously the worktree's handling of events inside gitdirs looked like
this:

- First, deduplicate paths for which we received events by dropping any
path that is a suffix of another one
- Then, filter out events for deliberately ignored paths like
`.git/index.lock`
- Finally, collect a set of affected gitdirs based on the paths that
remain

This doesn't work on Windows, because when events occur for paths inside
`.git` we also get an event for `.git` itself. The deduplication steps
drops `.git/index.lock` before we get the chance to filter it out in the
second step. This causes us to rescan git state unnecessarily on
Windows.

This PR fixes the issue by moving the filtering of ignored paths, and
also the handling of `.git/info/exclude`, to just before the
deduplication step. We also filter out events for the `.git` directory
itself, so that if the batch of events looks like `[".git",
".git/index.lock"]`, we don't trigger `WorktreeUpdatedGitRepositories`.

Self-Review Checklist:

- [ ] I've reviewed my own diff for quality, security, and reliability
- [ ] Unsafe blocks (if any) have justifying comments
- [ ] The content is consistent with the [UI/UX
checklist](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist)
- [ ] Tests cover the new/changed behavior
- [ ] Performance impact has been considered and is acceptable

Closes #ISSUE

Release Notes:

- N/A or Added/Fixed/Improved ...
2026-04-23 07:23:19 +00:00
..
src git: Correctly filter ignored paths inside gitdirs on all platforms (#54548) 2026-04-23 07:23:19 +00:00
tests/integration git: Correctly filter ignored paths inside gitdirs on all platforms (#54548) 2026-04-23 07:23:19 +00:00
Cargo.toml Remove unreferenced dev dependencies (#51093) 2026-03-09 13:22:12 +01:00
LICENSE-GPL