# git: Reduce number of spawned git processes when retrieving default branch \(\#59087\) · gitcafe/zed

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

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

Visibility: public

Requested revision: 346d3605cf86c742561e696717b51c9f8bfb06b9

Requested commit: 346d3605cf86c742561e696717b51c9f8bfb06b9

Commit: 346d3605cf86c742561e696717b51c9f8bfb06b9

Tree: 46fff3e5bc1b0bed382150f3a655b77a885a6705

Author: Lukas Geiger

Committer: GitHub

## Message

```
git: Reduce number of spawned git processes when retrieving default branch (#59087)

Retrieving the default branch currently spawns up to 5 git processes
sequentially which isn't ideal.
This PR switches to a `git for-each-ref` and `git config` call to do the
same checks while requiring spawning less git processes. I tested this
in the UI and added a unit test to verify that the behaviour doesn't
change.

This PR follows the approach from #59069.

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 adheres to Zed's UI standards
([UX/UI](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist)
and
[icon](https://github.com/zed-industries/zed/blob/main/crates/icons/README.md)
guidelines)
- [x] Tests cover the new/changed behavior
- [x] Performance impact has been considered and is acceptable

Release Notes:

- Improved performance of retrieving default git branch
```

## Parents

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

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