# git: Reduce amount of git commands when checking for pushed commits \(\#59069\) · gitcafe/zed

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

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

Visibility: public

Requested revision: 5e514f462413620573038ceafaa84e82f93d54f1

Requested commit: 5e514f462413620573038ceafaa84e82f93d54f1

Commit: 5e514f462413620573038ceafaa84e82f93d54f1

Tree: 23823fc5d4597ceddc6263aa1216d836bb08a73c

Author: Lukas Geiger

Committer: GitHub

## Message

```
git: Reduce amount of git commands when checking for pushed commits (#59069)

When uncommiting we check whether the commit already exists on a remote
branch. This currently spawns a lot of git processes to do so,
especially when having multiple remotes.

This PR switches this to a single `git for-each-ref` call to do the same
checks. I tested this in the UI and added some unit tests to verify this
behaviour.

This is a followup on #59053, #59044 and #59042 with the goal to reduce
overhead of the git handling.

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 git uncommit
```

## Parents

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

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