# git: Fix \`\.git\` directory being removed from watcher when excluded via \`file_scan_exclusions\` \(\#57895\) · gitcafe/zed

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

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

Visibility: public

Requested revision: 2252cad9b90459dc4532f3057198910507e45bfb

Requested commit: 2252cad9b90459dc4532f3057198910507e45bfb

Commit: 2252cad9b90459dc4532f3057198910507e45bfb

Tree: ea6790e9c1719fe84ed3eedf03361d6e9dd3f189

Author: Alvaro Parker

Committer: GitHub

## Message

````
git: Fix `.git` directory being removed from watcher when excluded via `file_scan_exclusions` (#57895)

Self-Review Checklist:

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

Closes #57888 

Commit `c19cc4c51e0f64eec42168943050f2deeccaa076` introduced the bug on
#50412 . This change modified the `remove_path` function to also remove
the path from the watcher:


https://github.com/zed-industries/zed/blob/f0341c96a17630e5dfb441701441945dbb2a605a/crates/worktree/src/worktree.rs#L3218-L3220

And when a user modified the global setting and doesn't include `.git`
in it, like:

```jsonc
// ~/.config/zed/settings.json
{
  "file_scan_exclusions": ["foo"]
}
```

But then includes it on their local project settings: 

```jsonc
// ~/my/local/project/.zed/settings.json
{
  "file_scan_exclusions": ["**/.git"]
}
```

It causes zed to stop watching for changes on `.git` 

Release Notes:

- Fixed bug where zed stopped watching change on `.git` directory if it
was added to the project local `file_scan_exclusions`
````

## Parents

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

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