Skip to content

git: Degrade gracefully when refreshing git state#57292

Merged
cole-miller merged 11 commits into
mainfrom
degrade-branches
May 25, 2026
Merged

git: Degrade gracefully when refreshing git state#57292
cole-miller merged 11 commits into
mainfrom
degrade-branches

Conversation

@cole-miller

@cole-miller cole-miller commented May 20, 2026

Copy link
Copy Markdown
Member

This PR changes the git store's compute_snapshot, which runs to update state that depends on the contents of .git, to degrade gracefully when fetching individual pieces of state fails. For example, when fetching the list of branches fails, instead of returning early from the function (leaving the previous git state snapshot in place with stale state), we continue with an empty list of branches. This prevents failures of individual git commands from making the entire git UI get stuck indefinitely.

Self-Review Checklist:

  • I've reviewed my own diff for quality, security, and reliability
  • Unsafe blocks (if any) have justifying comments
  • The content is consistent with the UI/UX checklist
  • Tests cover the new/changed behavior
  • Performance impact has been considered and is acceptable

Closes #ISSUE

Release Notes:

  • Fixed an issue where failing to fetch branches using the git CLI would prevent other git-related state from being updated.

@cla-bot cla-bot Bot added the cla-signed The user has signed the Contributor License Agreement label May 20, 2026
@zed-community-bot zed-community-bot Bot added the staff Pull requests authored by a current member of Zed staff label May 20, 2026
@cole-miller cole-miller changed the title git: Degrade gracefully when branches or worktrees can't be fetches git: Degrade gracefully when branches or worktrees can't be fetched May 20, 2026
Comment thread crates/project/src/git_store.rs Outdated
@cole-miller cole-miller changed the title git: Degrade gracefully when branches or worktrees can't be fetched git: Degrade gracefully when refreshing git state May 21, 2026
@cole-miller cole-miller requested a review from Anthony-Eid May 21, 2026 00:32
@cole-miller

Copy link
Copy Markdown
Member Author

So this branch turned up that we don't actually correctly handle renaming the root of a git repository--we had a test for that, test_rename_work_directory, but it was only passing because we retained the old RepositorySnapshot when compute_snapshot failed. I think we should fix that.

@cole-miller cole-miller added this pull request to the merge queue May 25, 2026
@cole-miller cole-miller removed this pull request from the merge queue due to a manual request May 25, 2026
@cole-miller cole-miller added this pull request to the merge queue May 25, 2026
Merged via the queue into main with commit bcfbf66 May 25, 2026
32 checks passed
@cole-miller cole-miller deleted the degrade-branches branch May 25, 2026 16:17
TomPlanche pushed a commit to TomPlanche/zed that referenced this pull request Jun 2, 2026
This PR changes the git store's `compute_snapshot`, which runs to update
state that depends on the contents of `.git`, to degrade gracefully when
fetching individual pieces of state fails. For example, when fetching
the list of branches fails, instead of returning early from the function
(leaving the previous git state snapshot in place with stale state), we
continue with an empty list of branches. This prevents failures of
individual git commands from making the entire git UI get stuck
indefinitely.

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 is consistent with the [UI/UX
checklist](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist)
- [ ] Tests cover the new/changed behavior
- [x] Performance impact has been considered and is acceptable

Closes #ISSUE

Release Notes:

- Fixed an issue where failing to fetch branches using the git CLI would
prevent other git-related state from being updated.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla-signed The user has signed the Contributor License Agreement staff Pull requests authored by a current member of Zed staff

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants