Skip to content

Commit 7182176

Browse files
committed
Check both worktree directory AND branch existence to avoid collisions
1 parent 63e872d commit 7182176

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

packages/agent/src/worktree-manager.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,12 @@ export class WorktreeManager {
178178
let attempts = 0;
179179
const maxAttempts = 100;
180180

181-
while ((await this.worktreeExists(name)) && attempts < maxAttempts) {
181+
// Check both worktree directory AND branch existence to avoid collisions
182+
while (
183+
((await this.worktreeExists(name)) ||
184+
(await this.gitManager.branchExists(name))) &&
185+
attempts < maxAttempts
186+
) {
182187
name = this.generateWorktreeName();
183188
attempts++;
184189
}

0 commit comments

Comments
 (0)