worktree: Add some info-level logging about added and removed repository entries (#26291)

Trying to track down a user's reported issue with parent repositories
not getting picked up.

Release Notes:

- N/A
This commit is contained in:
Cole Miller 2025-03-07 13:02:05 -05:00 committed by GitHub
parent 80fb88520f
commit b0b0b00fae
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -3424,6 +3424,7 @@ impl BackgroundScannerState {
} }
fn remove_path(&mut self, path: &Path) { fn remove_path(&mut self, path: &Path) {
log::info!("background scanner removing path {path:?}");
let mut new_entries; let mut new_entries;
let removed_entries; let removed_entries;
{ {
@ -3479,7 +3480,14 @@ impl BackgroundScannerState {
.git_repositories .git_repositories
.retain(|id, _| removed_ids.binary_search(id).is_err()); .retain(|id, _| removed_ids.binary_search(id).is_err());
self.snapshot.repositories.retain(&(), |repository| { self.snapshot.repositories.retain(&(), |repository| {
!repository.work_directory.path_key().0.starts_with(path) let retain = !repository.work_directory.path_key().0.starts_with(path);
if !retain {
log::info!(
"dropping repository entry for {:?}",
repository.work_directory
);
}
retain
}); });
#[cfg(test)] #[cfg(test)]
@ -3534,12 +3542,14 @@ impl BackgroundScannerState {
fs: &dyn Fs, fs: &dyn Fs,
watcher: &dyn Watcher, watcher: &dyn Watcher,
) -> Option<LocalRepositoryEntry> { ) -> Option<LocalRepositoryEntry> {
log::info!("insert git reposiutory for {dot_git_path:?}");
let work_dir_id = self let work_dir_id = self
.snapshot .snapshot
.entry_for_path(work_directory.path_key().0) .entry_for_path(work_directory.path_key().0)
.map(|entry| entry.id)?; .map(|entry| entry.id)?;
if self.snapshot.git_repositories.get(&work_dir_id).is_some() { if self.snapshot.git_repositories.get(&work_dir_id).is_some() {
log::info!("existing git repository for {work_directory:?}");
return None; return None;
} }
@ -3547,6 +3557,7 @@ impl BackgroundScannerState {
let t0 = Instant::now(); let t0 = Instant::now();
let repository = fs.open_repo(&dot_git_abs_path)?; let repository = fs.open_repo(&dot_git_abs_path)?;
log::info!("opened git repo for {dot_git_abs_path:?}");
let repository_path = repository.path(); let repository_path = repository.path();
watcher.add(&repository_path).log_err()?; watcher.add(&repository_path).log_err()?;
@ -3605,6 +3616,7 @@ impl BackgroundScannerState {
.git_repositories .git_repositories
.insert(work_dir_id, local_repository.clone()); .insert(work_dir_id, local_repository.clone());
log::info!("inserting new local git repository");
Some(local_repository) Some(local_repository)
} }
} }
@ -4352,7 +4364,7 @@ impl BackgroundScanner {
} }
let ancestor_dot_git = ancestor.join(*DOT_GIT); let ancestor_dot_git = ancestor.join(*DOT_GIT);
log::debug!("considering ancestor: {ancestor_dot_git:?}"); log::info!("considering ancestor: {ancestor_dot_git:?}");
// Check whether the directory or file called `.git` exists (in the // Check whether the directory or file called `.git` exists (in the
// case of worktrees it's a file.) // case of worktrees it's a file.)
if self if self
@ -4361,7 +4373,6 @@ impl BackgroundScanner {
.await .await
.is_ok_and(|metadata| metadata.is_some()) .is_ok_and(|metadata| metadata.is_some())
{ {
log::debug!(".git path exists");
if index != 0 { if index != 0 {
// We canonicalize, since the FS events use the canonicalized path. // We canonicalize, since the FS events use the canonicalized path.
if let Some(ancestor_dot_git) = if let Some(ancestor_dot_git) =
@ -4372,7 +4383,7 @@ impl BackgroundScanner {
.strip_prefix(ancestor) .strip_prefix(ancestor)
.unwrap() .unwrap()
.into(); .into();
log::debug!( log::info!(
"inserting parent git repo for this worktree: {location_in_repo:?}" "inserting parent git repo for this worktree: {location_in_repo:?}"
); );
// We associate the external git repo with our root folder and // We associate the external git repo with our root folder and
@ -4395,12 +4406,10 @@ impl BackgroundScanner {
// Reached root of git repository. // Reached root of git repository.
break; break;
} else {
log::debug!(".git path doesn't exist");
} }
} }
log::debug!("containing git repository: {containing_git_repository:?}"); log::info!("containing git repository: {containing_git_repository:?}");
let (scan_job_tx, scan_job_rx) = channel::unbounded(); let (scan_job_tx, scan_job_rx) = channel::unbounded();
{ {
@ -4825,7 +4834,7 @@ impl BackgroundScanner {
log::error!("skipping excluded directory {:?}", job.path); log::error!("skipping excluded directory {:?}", job.path);
return Ok(()); return Ok(());
} }
log::debug!("scanning directory {:?}", job.path); log::info!("scanning directory {:?}", job.path);
root_abs_path = snapshot.abs_path().clone(); root_abs_path = snapshot.abs_path().clone();
root_char_bag = snapshot.root_char_bag; root_char_bag = snapshot.root_char_bag;
} }
@ -5407,7 +5416,7 @@ impl BackgroundScanner {
} }
fn update_git_repositories(&self, dot_git_paths: Vec<PathBuf>) -> Task<()> { fn update_git_repositories(&self, dot_git_paths: Vec<PathBuf>) -> Task<()> {
log::debug!("reloading repositories: {dot_git_paths:?}"); log::info!("reloading repositories: {dot_git_paths:?}");
let mut status_updates = Vec::new(); let mut status_updates = Vec::new();
{ {