aboutsummaryrefslogtreecommitdiff
path: root/src/app/api/worktrees
diff options
context:
space:
mode:
authorOgulcan Celik <ogulcancelik@gmail.com>2026-06-22 00:51:00 +0300
committerOgulcan Celik <ogulcancelik@gmail.com>2026-06-22 00:51:00 +0300
commit89ca3ba933eaf493234912972be8236c9c2493e5 (patch)
tree508a0489cf3aa15f6d454a1c86697b0a7ba4ed72 /src/app/api/worktrees
parenta5182282a490cfb60b22776257edc5ac0fce6adc (diff)
fix: check out existing branches for worktree create
refs #729
Diffstat (limited to 'src/app/api/worktrees')
-rw-r--r--src/app/api/worktrees/deferred.rs23
1 files changed, 12 insertions, 11 deletions
diff --git a/src/app/api/worktrees/deferred.rs b/src/app/api/worktrees/deferred.rs
index 19794a6e..f63a47fd 100644
--- a/src/app/api/worktrees/deferred.rs
+++ b/src/app/api/worktrees/deferred.rs
@@ -159,12 +159,6 @@ impl App {
self.pending_api_worktree_creates
.insert(checkout_key.clone(), operation_id);
- let command = crate::worktree::build_worktree_add_new_branch_command(
- &source.source_checkout_path,
- &checkout_path,
- &branch,
- &base,
- );
let parent_dir = checkout_path.parent().map(Path::to_path_buf);
let source_workspace_id = source
.workspace_idx
@@ -191,15 +185,22 @@ impl App {
respond_to,
};
let path = checkout_path;
+ let source_checkout_path = api_request.source_checkout_path.clone();
let event_tx = self.event_tx.clone();
std::thread::spawn(move || {
let result = if let Some(parent_dir) = parent_dir {
- std::fs::create_dir_all(&parent_dir)
- .map_err(|err| err.to_string())
- .and_then(|()| crate::worktree::run_worktree_command(&command))
+ std::fs::create_dir_all(&parent_dir).map_err(|err| err.to_string())
} else {
- crate::worktree::run_worktree_command(&command)
- };
+ Ok(())
+ }
+ .and_then(|()| {
+ crate::worktree::run_worktree_add_command(
+ &source_checkout_path,
+ &path,
+ &branch,
+ &base,
+ )
+ });
let _ = event_tx.blocking_send(AppEvent::WorktreeAddFinished(Box::new(
crate::events::WorktreeAddResult {
path,