Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
worktree: Fix `.git` modified events not being correctly filtered out (#54329)
Lukas Wirth0ba60d8a4460
diff --git a/crates/fs/src/fs.rs b/crates/fs/src/fs.rsindex e44f5576462..fa42c436f1b 100644--- a/crates/fs/src/fs.rs+++ b/crates/fs/src/fs.rs@@ -1889,7 +1889,10 @@ impl FakeFs {drop(repo_state);if emit_git_event {- state.emit_event([(dot_git, Some(PathEventKind::Changed))]);+ state.emit_event([(+ dot_git.join("fake_git_repo_event"),+ Some(PathEventKind::Changed),+ )]);}Ok(result)@@ -1944,7 +1947,10 @@ impl FakeFs {if emit_git_event {drop(repo_state);- state.emit_event([(canonical_path, Some(PathEventKind::Changed))]);+ state.emit_event([(+ canonical_path.join("fake_git_repo_event"),+ Some(PathEventKind::Changed),+ )]);}Ok(result)diff --git a/crates/worktree/src/worktree.rs b/crates/worktree/src/worktree.rsindex 990ed4fd54c..8d66c375a24 100644--- a/crates/worktree/src/worktree.rs+++ b/crates/worktree/src/worktree.rs@@ -3295,7 +3295,7 @@ impl BackgroundScannerState {}}-async fn is_git_dir(path: &Path, fs: &dyn Fs) -> bool {+async fn is_dot_git(path: &Path, fs: &dyn Fs) -> bool {if let Some(file_name) = path.file_name()&& file_name == DOT_GIT{@@ -4291,7 +4291,7 @@ impl BackgroundScanner {let mut dot_git_paths = None;for ancestor in abs_path.as_path().ancestors() {- if is_git_dir(ancestor, self.fs.as_ref()).await {+ if is_dot_git(ancestor, self.fs.as_ref()).await {let path_in_git_dir = abs_path.as_path().strip_prefix(ancestor)@@ -4312,15 +4312,7 @@ impl BackgroundScanner {let is_dot_git_changed = {path_in_git_dir == Path::new("")&& event.kind == Some(PathEventKind::Changed)- && abs_path- .strip_prefix(root_canonical_path)- .ok()- .and_then(|it| RelPath::new(it, PathStyle::local()).ok())- .is_some_and(|it| {- snapshot- .entry_for_path(&it)- .is_some_and(|entry| entry.kind == EntryKind::Dir)- })+ && self.fs.is_dir(abs_path.as_path()).await};let condition = skipped_files_in_dot_git.iter().any(|skipped| {OsStr::new(skipped) == path_in_git_dir.as_path().as_os_str()