From 1766ea6d3c35855f5ae27c294e4d52818acf5f06 Mon Sep 17 00:00:00 2001 From: "zed-zippy[bot]" <234243425+zed-zippy[bot]@users.noreply.github.com> Date: Tue, 21 Apr 2026 19:05:59 +0000 Subject: [PATCH] git: Revert skipping of events for the `.git` directory itself (#54443) (cherry-pick to preview) (#54445) Cherry-pick of #54443 to preview ---- This reverts #54329 and the part of #52499 that was an earlier attempt at the same thing, which caused us to incorrectly miss git state updates on Windows. cc @Veykril it seems like we need to find a different way to fix the problem of `.git` scanning cycles. Self-Review Checklist: - [x] I've reviewed my own diff for quality, security, and reliability - [x] Unsafe blocks (if any) have justifying comments - [x] The content is consistent with the [UI/UX checklist](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist) - [x] Tests cover the new/changed behavior - [x] Performance impact has been considered and is acceptable Release Notes: - Fixed a bug causing stale git state on Windows. Co-authored-by: Cole Miller --- crates/worktree/src/worktree.rs | 18 ++---------------- 1 file changed, 2 insertions(+), 16 deletions(-) diff --git a/crates/worktree/src/worktree.rs b/crates/worktree/src/worktree.rs index 55d40e1416307622f71c244dc12e79884a76bbac..7436dc5437546d87ed4060c848b11b4af4c0e5ad 100644 --- a/crates/worktree/src/worktree.rs +++ b/crates/worktree/src/worktree.rs @@ -8,8 +8,7 @@ use clock::ReplicaId; use collections::{HashMap, HashSet, VecDeque}; use encoding_rs::Encoding; use fs::{ - Fs, MTime, PathEvent, PathEventKind, RemoveOptions, TrashedEntry, Watcher, copy_recursive, - read_dir_items, + Fs, MTime, PathEvent, RemoveOptions, TrashedEntry, Watcher, copy_recursive, read_dir_items, }; use futures::{ FutureExt as _, Stream, StreamExt, @@ -4302,24 +4301,11 @@ impl BackgroundScanner { } if let Some((dot_git_abs_path, path_in_git_dir)) = dot_git_paths { - // We ignore `""` as well, as that is going to be the - // `.git` folder itself. WE do not care about it, if - // there are changes within we will see them, we need - // this ignore to prevent us from accidentally observing - // the ignored created file due to the events not being - // empty after filtering. - - let is_dot_git_changed = { - path_in_git_dir == Path::new("") - && event.kind == Some(PathEventKind::Changed) - && 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() }) || skipped_dirs_in_dot_git .iter() - .any(|skipped_git_subdir| path_in_git_dir.starts_with(skipped_git_subdir)) - || is_dot_git_changed; + .any(|skipped_git_subdir| path_in_git_dir.starts_with(skipped_git_subdir)); if condition { log::debug!( "ignoring event {abs_path:?} as it's in the .git directory among skipped files or directories"