Represent git statuses more faithfully (#23082)

First, parse the output of `git status --porcelain=v1` into a
representation that can handle the full "grammar" and doesn't lose
information.

Second, as part of pushing this throughout the codebase, expand the use
of the existing `GitSummary` type to all the places where status
propagation is in play (i.e., anywhere we're dealing with a mix of files
and directories), and get rid of the previous `GitSummary ->
GitFileStatus` conversion.

- [x] Synchronize new representation over collab
  - [x] Update zed.proto
  - [x] Update DB models
- [x] Update `GitSummary` and summarization for the new `FileStatus`
- [x] Fix all tests
  - [x] worktree
  - [x] collab
- [x] Clean up `FILE_*` constants
- [x] New collab tests to exercise syncing of complex statuses
- [x] Run it locally and make sure it looks good

Release Notes:

- N/A

---------

Co-authored-by: Mikayla <mikayla@zed.dev>
Co-authored-by: Conrad <conrad@zed.dev>
This commit is contained in:
Cole Miller 2025-01-15 19:01:38 -05:00 committed by GitHub
parent 224f3d4746
commit a41d72ee81
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
24 changed files with 1015 additions and 552 deletions

View file

@ -1784,7 +1784,9 @@ message RepositoryEntry {
message StatusEntry {
string repo_path = 1;
GitStatus status = 2;
// Can be removed once collab's min version is >=0.171.0.
GitStatus simple_status = 2;
GitFileStatus status = 3;
}
enum GitStatus {
@ -1792,6 +1794,31 @@ enum GitStatus {
Modified = 1;
Conflict = 2;
Deleted = 3;
Updated = 4;
TypeChanged = 5;
Renamed = 6;
Copied = 7;
Unmodified = 8;
}
message GitFileStatus {
oneof variant {
Untracked untracked = 1;
Ignored ignored = 2;
Unmerged unmerged = 3;
Tracked tracked = 4;
}
message Untracked {}
message Ignored {}
message Unmerged {
GitStatus first_head = 1;
GitStatus second_head = 2;
}
message Tracked {
GitStatus index_status = 1;
GitStatus worktree_status = 2;
}
}
message BufferState {