# git: Correctly filter ignored paths inside gitdirs on all platforms \(\#54548\) · gitcafe/zed

[View on GitCafe](https://git.cafe/gitcafe/zed/commit/cd944ad8d6a2faf5954eb693171dba64c67d7917)

Repository: [gitcafe/zed](https://git.cafe/gitcafe/zed)

Visibility: public

Requested revision: cd944ad8d6a2faf5954eb693171dba64c67d7917

Requested commit: cd944ad8d6a2faf5954eb693171dba64c67d7917

Commit: cd944ad8d6a2faf5954eb693171dba64c67d7917

Tree: f45e0d8d36da3db94d2d4e8561b29286eb787054

Author: Cole Miller

Committer: GitHub

## Message

```
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 ...
```

## Parents

- [3aa173ab1cb3320773e367ebef476b49b8aee46d](https://git.cafe/gitcafe/zed/commit/3aa173ab1cb3320773e367ebef476b49b8aee46d?format=markdown)

[Source at this commit](https://git.cafe/gitcafe/zed/tree/cd944ad8d6a2faf5954eb693171dba64c67d7917?format=markdown)
