# Use repository mutex more sparingly\. Don't hold it while running git status\. \(\#12489\) · gitcafe/zed

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

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

Visibility: public

Requested revision: 8f942bf647c62ba4de9598ded569daacb125229e

Requested commit: 8f942bf647c62ba4de9598ded569daacb125229e

Commit: 8f942bf647c62ba4de9598ded569daacb125229e

Tree: 945ca18440889a14dd00affd1a675fce013d0d6b

Author: Max Brunsfeld

Committer: GitHub

## Message

```
Use repository mutex more sparingly. Don't hold it while running git status. (#12489)

Previously, each git `Repository` object was held inside of a mutex.
This was needed because libgit2's Repository object is (as one would
expect) not thread safe. But now, the two longest-running git operations
that Zed performs, (`status` and `blame`) do not use libgit2 - they
invoke the `git` executable. For these operations, it's not necessary to
hold a lock on the repository.

In this PR, I've moved our mutex usage so that it only wraps the libgit2
calls, not our `git` subprocess spawns. The main user-facing impact of
this is that the UI is much more responsive when initially opening a
project with a very large git repository (e.g. `chromium`, `webkit`,
`linux`).

Release Notes:

- Improved Zed's responsiveness when initially opening a project
containing a very large git repository.
```

## Parents

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

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