git: Don't consider $HOME as containing git repository unless it's opened directly (#25948)
When a worktree is created, we walk up the ancestors of the root path trying to find a git repository. In particular, if your `$HOME` is a git repository and you open some subdirectory of `$HOME` that's *not* a git repository, we end up scanning `$HOME` and everything under it looking for changed and untracked files, which is often pretty slow. Consistency here is not very useful and leads to a bad experience. This PR adds a special case to not consider `$HOME` as a containing git repository, unless you ask for it by doing the equivalent of `zed ~`. Release Notes: - Changed the behavior of git features to not treat `$HOME` as a git repository unless opened directly
This commit is contained in:
parent
9e2b7bc5dc
commit
dc3158c8ce
3 changed files with 87 additions and 1 deletions
|
@ -4292,7 +4292,11 @@ impl BackgroundScanner {
|
|||
let mut containing_git_repository = None;
|
||||
for (index, ancestor) in root_abs_path.as_path().ancestors().enumerate() {
|
||||
if index != 0 {
|
||||
if let Ok(ignore) =
|
||||
if Some(ancestor) == self.fs.home_dir().as_deref() {
|
||||
// Unless $HOME is itself the worktree root, don't consider it as a
|
||||
// containing git repository---expensive and likely unwanted.
|
||||
break;
|
||||
} else if let Ok(ignore) =
|
||||
build_gitignore(&ancestor.join(*GITIGNORE), self.fs.as_ref()).await
|
||||
{
|
||||
self.state
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue