git: Optimize git HEAD state resolution - #59044
Merged
Merged
Conversation
5 tasks
Veykril
enabled auto-merge
June 15, 2026 07:14
hicder
pushed a commit
to hicder/zed
that referenced
this pull request
Jun 15, 2026
…ed-industries#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 zed-industries#59053, zed-industries#59044 and zed-industries#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
auto-merge was automatically disabled
June 15, 2026 09:52
Head branch was pushed to by a user without write access
Contributor
Author
|
57e0827 should fix CI by adapting the fake git mock |
Veykril
approved these changes
Jun 15, 2026
Veykril
enabled auto-merge
June 15, 2026 09:56
This was referenced Jun 18, 2026
Closed
This was referenced Jul 1, 2026
This was referenced Jul 10, 2026
jolutz
pushed a commit
to jolutz/zed
that referenced
this pull request
Aug 8, 2026
…ed-industries#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 zed-industries#59053, zed-industries#59044 and zed-industries#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
jolutz
pushed a commit
to jolutz/zed
that referenced
this pull request
Aug 8, 2026
Currently zed runs `git rev-parse HEAD` and `git show` sequentially to get the git `HEAD` state in `compute_snapshot`. `git show` already natively resolves the `HEAD` commit so we can retrieve all info in a single process spawn which speeds things up and removes one git background process. Followup on zed-industries#59042 in the hope to improve performance of working with large git repos over SSH. 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 HEAD state resolution --------- Co-authored-by: Lukas Wirth <lukas@zed.dev>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Currently zed runs
git rev-parse HEADandgit showsequentially to get the gitHEADstate incompute_snapshot.git showalready natively resolves theHEADcommit so we can retrieve all info in a single process spawn which speeds things up and removes one git background process.Followup on #59042 in the hope to improve performance of working with large git repos over SSH.
Self-Review Checklist:
Release Notes: