Fix the worktree's repository_for_path (#24279)
Go back to a less optimized implementation for now since the custom cursor target seems to have some bugs. Release Notes: - Fixed missing git blame and status output in some projects with multiple git repositories
This commit is contained in:
parent
868e3f75b2
commit
6b29616c95
1 changed files with 4 additions and 23 deletions
|
@ -2682,21 +2682,10 @@ impl Snapshot {
|
||||||
|
|
||||||
/// Get the repository whose work directory contains the given path.
|
/// Get the repository whose work directory contains the given path.
|
||||||
pub fn repository_for_path(&self, path: &Path) -> Option<&RepositoryEntry> {
|
pub fn repository_for_path(&self, path: &Path) -> Option<&RepositoryEntry> {
|
||||||
let mut cursor = self.repositories.cursor::<PathProgress>(&());
|
self.repositories
|
||||||
let mut repository = None;
|
.iter()
|
||||||
|
.filter(|repo| repo.work_directory.directory_contains(path))
|
||||||
// Git repositories may contain other git repositories. As a side effect of
|
.last()
|
||||||
// lexicographic sorting by path, deeper repositories will be after higher repositories
|
|
||||||
// So, let's loop through every matching repository until we can't find any more to find
|
|
||||||
// the deepest repository that could contain this path.
|
|
||||||
while cursor.seek_forward(&PathTarget::Contains(path), Bias::Left, &())
|
|
||||||
&& cursor.item().is_some()
|
|
||||||
{
|
|
||||||
repository = cursor.item();
|
|
||||||
cursor.next(&());
|
|
||||||
}
|
|
||||||
|
|
||||||
repository
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Given an ordered iterator of entries, returns an iterator of those entries,
|
/// Given an ordered iterator of entries, returns an iterator of those entries,
|
||||||
|
@ -5982,7 +5971,6 @@ impl<'a> Iterator for Traversal<'a> {
|
||||||
enum PathTarget<'a> {
|
enum PathTarget<'a> {
|
||||||
Path(&'a Path),
|
Path(&'a Path),
|
||||||
Successor(&'a Path),
|
Successor(&'a Path),
|
||||||
Contains(&'a Path),
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> PathTarget<'a> {
|
impl<'a> PathTarget<'a> {
|
||||||
|
@ -5996,13 +5984,6 @@ impl<'a> PathTarget<'a> {
|
||||||
Ordering::Equal
|
Ordering::Equal
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
PathTarget::Contains(path) => {
|
|
||||||
if path.starts_with(other) {
|
|
||||||
Ordering::Equal
|
|
||||||
} else {
|
|
||||||
Ordering::Greater
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue