zed/crates/remote_server
Cole Miller 8624bf6689
git: Fix diff hunks not being removed on restore in remote projects (#54823)
Closes #48032 

When restoring a diff hunk, we first unstage it unconditionally. That
unstaging operation is a no-op in terms of the index text if the hunk
was already not staged, but previously we would still always do
`spawn_set_index_text_job` and bump the
`hunk_staging_operation_count_as_of_write`. Bumping that count in turn
causes us to skip a diff recalculation in response to the change in the
buffer's text. That works out fine in the local case, because when the
worktree picks up the write to `.git/index` we kick off another diff
recalculation which is not skipped. But in the remote case, we don't get
an `UpdateDiffBases` proto message if the index text didn't actually
change, so there is no subsequent diff calculation to do the cleanup,
and we end up with a stale no-op hunk.

This PR fixes the issue by skipping the write to the index and the
`hunk_staging_operation_count_as_of_write` bump if the new and old index
texts are the same.

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)
- [x] Tests cover the new/changed behavior
- [x] Performance impact has been considered and is acceptable

Closes #ISSUE

Release Notes:

- Fixed a bug where restoring diff hunks in remote projects would leave
stale no-op hunks in the UI.
2026-05-07 17:40:28 +00:00
..
src git: Fix diff hunks not being removed on restore in remote projects (#54823) 2026-05-07 17:40:28 +00:00
build.rs releases: Add build number to Nightly builds (#42990) 2025-11-24 13:34:04 +01:00
Cargo.toml Remove smol as a dependency from a bunch of crates (#53603) 2026-04-24 10:29:51 +00:00
LICENSE-GPL