Skip to content

armgit / zed

Public Imported from GitHub
0

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.

git: Only save dirty files during staging (#41047)

Conrad Irwin1ce9a85a1a37
diff --git a/crates/language/src/buffer.rs b/crates/language/src/buffer.rs
index 6e4007fdae2..41c0e3eec8e 100644
--- a/crates/language/src/buffer.rs
+++ b/crates/language/src/buffer.rs
@@ -2008,7 +2008,7 @@ impl Buffer {
self.end_transaction(cx)
}
- fn has_unsaved_edits(&self) -> bool {
+ pub fn has_unsaved_edits(&self) -> bool {
let (last_version, has_unsaved_edits) = self.has_unsaved_edits.take();
if last_version == self.version {
diff --git a/crates/project/src/git_store.rs b/crates/project/src/git_store.rs
index 8612c739a01..5867881d536 100644
--- a/crates/project/src/git_store.rs
+++ b/crates/project/src/git_store.rs
@@ -3618,6 +3618,7 @@ impl Repository {
.read(cx)
.file()
.is_some_and(|file| file.disk_state().exists())
+ && buffer.read(cx).has_unsaved_edits()
{
save_futures.push(buffer_store.save_buffer(buffer, cx));
}
@@ -3684,6 +3685,7 @@ impl Repository {
.read(cx)
.file()
.is_some_and(|file| file.disk_state().exists())
+ && buffer.read(cx).has_unsaved_edits()
{
save_futures.push(buffer_store.save_buffer(buffer, cx));
}