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

Closes #40581

Release Notes:

- git: No longer save clean files when staging (to avoid triggering
unnecessary rebuilds in external file watchers like vite)
This commit is contained in:
Conrad Irwin
2025-10-23 20:53:19 +00:00
committed by GitHub
parent 1966d4c818
commit 1ce9a85a1a
2 changed files with 3 additions and 1 deletions
+1 -1
View File
@@ -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 {
+2
View File
@@ -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));
}