# Fix git stage race condition with delayed fs events \(\#27036\) · gitcafe/zed

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

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

Visibility: public

Requested revision: 7f2e3fb5bdd0bdcb20d838734ffb625147528cff

Requested commit: 7f2e3fb5bdd0bdcb20d838734ffb625147528cff

Commit: 7f2e3fb5bdd0bdcb20d838734ffb625147528cff

Tree: 606003254b37c767ac862c144e3c278a7d2a4149

Author: João Marcos

Committer: GitHub

## Message

```
Fix git stage race condition with delayed fs events (#27036)

This PR adds a failing test `test_staging_hunks_with_delayed_fs_event`
and makes it pass

Also skips a queued read for git diff states if another read was
requested (less work)

This still doesn't catch all race conditions, but the PR is getting long
so I'll yield this and start another branch

Release Notes:

- N/A
```

## Parents

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

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