# worktree: Fix race condition when a root of worktree is \.git directory \(\#12995\) · gitcafe/zed

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

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

Visibility: public

Requested revision: 14bf07c91626d8e821577923d1eeeac57711e769

Requested commit: 14bf07c91626d8e821577923d1eeeac57711e769

Commit: 14bf07c91626d8e821577923d1eeeac57711e769

Tree: 2684f4299e76ff5a7e2fc931f5abe0956a0d4683

Author: Piotr Osiewicz

Committer: GitHub

## Message

```
worktree: Fix race condition when a root of worktree is .git directory (#12995)

It was possible to unload a root of worktree when it was a .git
directory; due to that, test_fs_events_in_dot_git_worktree was sometimes
stuck in an infinite loop on CI.

The gist of an issue is that when .git dir is a root dir, then modifying
a file within this directory could sometimes unload the .git dir; the
test went into an infinite loop when the first event in an filesystem
stream was not the event for the file creation, but for a dir
modification. In that case we'd unload the root directory and a
subsequent event for file creation would never be registered, leading to
the test being stuck waiting for it to happen.

This commit alleviates it by special-casing worktrees rooted in .git
directories.



Release Notes:

- Fixed a possible hang when opening a worktree in .git directory.
```

## Parents

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

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