mirror of
https://github.com/zed-industries/zed.git
synced 2025-01-10 20:41:59 +00:00
worktree: Do not scan for .gitignore files beyond project root. (#8189)
This has been fixed and reported before (and got lost in gpui1->gpui2 transition); https://github.com/zed-industries/zed/issues/5749#issuecomment-1959217319 Release Notes: - Fixed .gitignore files beyond the first .git directory being respected by the worktree (zed-industries/zed#5749).
This commit is contained in:
parent
95d5ea7edc
commit
94bc216bbd
1 changed files with 25 additions and 13 deletions
|
@ -2252,11 +2252,16 @@ impl LocalSnapshot {
|
||||||
|
|
||||||
fn ignore_stack_for_abs_path(&self, abs_path: &Path, is_dir: bool) -> Arc<IgnoreStack> {
|
fn ignore_stack_for_abs_path(&self, abs_path: &Path, is_dir: bool) -> Arc<IgnoreStack> {
|
||||||
let mut new_ignores = Vec::new();
|
let mut new_ignores = Vec::new();
|
||||||
for ancestor in abs_path.ancestors().skip(1) {
|
for (index, ancestor) in abs_path.ancestors().enumerate() {
|
||||||
if let Some((ignore, _)) = self.ignores_by_parent_abs_path.get(ancestor) {
|
if index > 0 {
|
||||||
new_ignores.push((ancestor, Some(ignore.clone())));
|
if let Some((ignore, _)) = self.ignores_by_parent_abs_path.get(ancestor) {
|
||||||
} else {
|
new_ignores.push((ancestor, Some(ignore.clone())));
|
||||||
new_ignores.push((ancestor, None));
|
} else {
|
||||||
|
new_ignores.push((ancestor, None));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ancestor.join(&*DOT_GIT).is_dir() {
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3319,14 +3324,21 @@ impl BackgroundScanner {
|
||||||
|
|
||||||
// Populate ignores above the root.
|
// Populate ignores above the root.
|
||||||
let root_abs_path = self.state.lock().snapshot.abs_path.clone();
|
let root_abs_path = self.state.lock().snapshot.abs_path.clone();
|
||||||
for ancestor in root_abs_path.ancestors().skip(1) {
|
for (index, ancestor) in root_abs_path.ancestors().enumerate() {
|
||||||
if let Ok(ignore) = build_gitignore(&ancestor.join(&*GITIGNORE), self.fs.as_ref()).await
|
if index != 0 {
|
||||||
{
|
if let Ok(ignore) =
|
||||||
self.state
|
build_gitignore(&ancestor.join(&*GITIGNORE), self.fs.as_ref()).await
|
||||||
.lock()
|
{
|
||||||
.snapshot
|
self.state
|
||||||
.ignores_by_parent_abs_path
|
.lock()
|
||||||
.insert(ancestor.into(), (ignore.into(), false));
|
.snapshot
|
||||||
|
.ignores_by_parent_abs_path
|
||||||
|
.insert(ancestor.into(), (ignore.into(), false));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ancestor.join(&*DOT_GIT).is_dir() {
|
||||||
|
// Reached root of git repository.
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue