Make add_local_worktree private and use find_or_create_local_worktree

The former always adds a worktree, even if we have one already in the
project and that could be misused. The public API should always search
for a local worktree containing the requested path first so that the
project can uphold invariants about which worktrees it has.
This commit is contained in:
Antonio Scandurra 2022-01-22 11:14:50 +01:00
parent 622aff3be2
commit 31dfd01fda
7 changed files with 98 additions and 79 deletions

View file

@ -723,7 +723,7 @@ impl Workspace {
cx: &mut ViewContext<Self>,
) -> Task<Result<ProjectPath>> {
let entry = self.project().update(cx, |project, cx| {
project.find_or_create_worktree_for_abs_path(abs_path, false, cx)
project.find_or_create_local_worktree(abs_path, false, cx)
});
cx.spawn(|_, cx| async move {
let (worktree, path) = entry.await?;