Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Restructure git diff state management to allow viewing buffers with different diff bases #21258

Merged
merged 22 commits into from
Dec 4, 2024

Conversation

maxbrunsfeld
Copy link
Collaborator

@maxbrunsfeld maxbrunsfeld commented Nov 28, 2024

This is a pure refactor of our Git diff state management. Buffers are no longer are associated with one single diff (the unstaged changes). Instead, there is an explicit project API for retrieving a buffer's unstaged changes, and the Editor view layer is responsible for choosing what diff to associate with a buffer.

The reason for this change is that we'll soon want to add multiple "git diff views" to Zed, one of which will show the uncommitted changes for a buffer. But that view will need to co-exist with other views of the same buffer, which may want to show the unstaged changes.

Todo

  • Get git gutter and git hunks working with new structure
  • Update editor tests to use new APIs
  • Update buffer tests
  • Restructure remoting/collab protocol
  • Update assertions about staged text in random_project_collaboration_tests
  • Move buffer tests for git diff management to a new spot, using the new APIs

Release Notes:

  • N/A

@cla-bot cla-bot bot added the cla-signed The user has signed the Contributor License Agreement label Nov 28, 2024
@maxbrunsfeld maxbrunsfeld merged commit a2115e7 into main Dec 4, 2024
11 of 12 checks passed
@maxbrunsfeld maxbrunsfeld deleted the staged-buffers branch December 4, 2024 23:02
maxbrunsfeld added a commit that referenced this pull request Dec 6, 2024
This fixes an error on nightly, introduced in
#21258, where diffs were not
shown for buffers that were added to multi-buffers after construction.

Release Notes:

- N/A
cole-miller added a commit that referenced this pull request Feb 4, 2025
This PR builds on #21258 to make it possible to use HEAD as a diff base.
The buffer store is extended to support holding multiple change sets,
and collab gains support for synchronizing the committed text of files
when any collaborator requires it.

Not implemented in this PR:

- Exposing the diff from HEAD to the user
- Decorating the diff from HEAD with information about which hunks are
staged

`test_random_multibuffer` now fails first at `SEED=13277`, similar to
the previous high-water mark, but with various bugs in the multibuffer
logic now shaken out.

Release Notes:

- N/A

---------

Co-authored-by: Max <[email protected]>
Co-authored-by: Ben <[email protected]>
Co-authored-by: Max Brunsfeld <[email protected]>
Co-authored-by: Conrad Irwin <[email protected]>
Co-authored-by: Conrad <[email protected]>
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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant