Use configured worktree directory in create_fresh_worktree

Richard Feldman created

Use worktrees_directory_for_repo instead of hardcoded
DEFAULT_WORKTREE_DIRECTORY, matching the collision path in
restore_archived_worktree.

Change summary

crates/sidebar/src/sidebar.rs | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)

Detailed changes

crates/sidebar/src/sidebar.rs 🔗

@@ -2541,10 +2541,14 @@ impl Sidebar {
         // Generate a new branch name for the fresh worktree.
         let branch_name = format!("restored-{}", row.id);
         let worktree_path = main_repo.update(cx, |repo, _cx| {
-            repo.path_for_new_linked_worktree(
-                &branch_name,
+            let setting = git_store::worktrees_directory_for_repo(
+                &repo.snapshot().original_repo_abs_path,
                 git::repository::DEFAULT_WORKTREE_DIRECTORY,
             )
+            .ok()
+            .map(|p| p.to_string_lossy().to_string())
+            .unwrap_or_default();
+            repo.path_for_new_linked_worktree(&branch_name, &setting)
         })?;
 
         // Create the fresh worktree.