Git improvements (#24238)

- **Base diffs on uncommitted changes**
- **Show added files in project diff view**
- **Fix git panel optimism**

Release Notes:

- Git: update diffs to be relative to HEAD instead of the index; to pave
the way for showing which hunks are staged

---------

Co-authored-by: Cole <cole@zed.dev>
This commit is contained in:
Conrad Irwin 2025-02-04 23:09:41 -07:00 committed by GitHub
parent 22b7042b9e
commit 0963401a8d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
11 changed files with 241 additions and 231 deletions

View file

@ -1285,7 +1285,7 @@ impl Editor {
let mut code_action_providers = Vec::new();
if let Some(project) = project.clone() {
get_unstaged_changes_for_buffers(
get_uncommitted_changes_for_buffer(
&project,
buffer.read(cx).all_buffers(),
buffer.clone(),
@ -13657,7 +13657,7 @@ impl Editor {
let buffer_id = buffer.read(cx).remote_id();
if self.buffer.read(cx).change_set_for(buffer_id).is_none() {
if let Some(project) = &self.project {
get_unstaged_changes_for_buffers(
get_uncommitted_changes_for_buffer(
project,
[buffer.clone()],
self.buffer.clone(),
@ -14413,7 +14413,7 @@ impl Editor {
}
}
fn get_unstaged_changes_for_buffers(
fn get_uncommitted_changes_for_buffer(
project: &Entity<Project>,
buffers: impl IntoIterator<Item = Entity<Buffer>>,
buffer: Entity<MultiBuffer>,
@ -14422,7 +14422,7 @@ fn get_unstaged_changes_for_buffers(
let mut tasks = Vec::new();
project.update(cx, |project, cx| {
for buffer in buffers {
tasks.push(project.open_unstaged_changes(buffer.clone(), cx))
tasks.push(project.open_uncommitted_changes(buffer.clone(), cx))
}
});
cx.spawn(|mut cx| async move {