# Fix the project diff sometimes missing updates \(\#40662\) · gitcafe/zed

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

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

Visibility: public

Requested revision: 8b6f3ec647cad5107e7f5eee4641ffb2e632dd82

Requested commit: 8b6f3ec647cad5107e7f5eee4641ffb2e632dd82

Commit: 8b6f3ec647cad5107e7f5eee4641ffb2e632dd82

Tree: 41655e8194cba2e68a2c39a97dadc9c72a2ecc60

Author: Cole Miller

Committer: GitHub

## Message

```
Fix the project diff sometimes missing updates (#40662)

This PR does two related things:

- First, it gets rid of the undifferentiated `RepositoryEvent::Updated`
in favor of three new events that have clearer definitions:
`BranchChanged`, `StashEntriesChanged`, and `StatusesChanged`. An
implication of this is that we no longer emit a `RepositoryEvent` unless
some git state changed; previously we would emit `RepositoryUpdated`
after doing a git status scan even if no statuses changed.
- Second, it changes the subscription strategy of the project diff to
make it update more robustly. Previously, the project diff only
subscribed to the `GitStore`, so it relied on getting a `GitStoreEvent`
when some buffer's diff hunks changed, even if the git status of the
buffer's file didn't change (e.g. a second hunk in a file that was
already modified). After this PR, it also subscribes to the individual
`BufferDiff` entities for buffers that have a git status, so the
`GitStore` is freed from that responsibility. This also fixes some real
cases where the previous strategy was not effective in keeping the
project diff up to date (captured in a test).

Release Notes:

- Fixed some cases where the project diff would fail to update in
response to git events.
```

## Parents

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

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