Don't create repos for invisible worktrees (#27894)

Closes #ISSUE

Release Notes:

- Fixed git repositories being added for files outside the project
This commit is contained in:
Cole Miller 2025-04-02 11:11:12 -04:00 committed by GitHub
parent d82bf132ca
commit 8ac4cbcbb9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 76 additions and 5 deletions

View file

@ -1017,7 +1017,18 @@ impl GitStore {
}
}
WorktreeStoreEvent::WorktreeUpdatedGitRepositories(worktree_id, changed_repos) => {
self.update_repositories_from_worktrees(
let Some(worktree) = worktree_store.read(cx).worktree_for_id(*worktree_id, cx)
else {
return;
};
if !worktree.read(cx).is_visible() {
log::debug!(
"not adding repositories for local worktree {:?} because it's not visible",
worktree.read(cx).abs_path()
);
return;
}
self.update_repositories_from_worktree(
project_environment.clone(),
next_repository_id.clone(),
downstream
@ -1027,9 +1038,7 @@ impl GitStore {
fs.clone(),
cx,
);
if let Some(worktree) = worktree_store.read(cx).worktree_for_id(*worktree_id, cx) {
self.local_worktree_git_repos_changed(worktree, changed_repos, cx);
}
self.local_worktree_git_repos_changed(worktree, changed_repos, cx);
}
_ => {}
}
@ -1050,7 +1059,7 @@ impl GitStore {
}
/// Update our list of repositories and schedule git scans in response to a notification from a worktree,
fn update_repositories_from_worktrees(
fn update_repositories_from_worktree(
&mut self,
project_environment: Entity<ProjectEnvironment>,
next_repository_id: Arc<AtomicU64>,