From 1ce9a85a1a374a6de7eef6137d35ae8e9568b0c0 Mon Sep 17 00:00:00 2001 From: Conrad Irwin Date: Thu, 23 Oct 2025 14:53:19 -0600 Subject: [PATCH] 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) --- crates/language/src/buffer.rs | 2 +- crates/project/src/git_store.rs | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/crates/language/src/buffer.rs b/crates/language/src/buffer.rs index 6e4007fdae2ad4af4c6ab56b82bff78c196b2d73..41c0e3eec8e8f4daaf5dff706dceea4159fedae1 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 8612c739a01c1a927dd071c73f789ea1ef4a2542..5867881d5366be0fcd0e3bfc68a2c3c184a49018 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)); }