File tree Expand file tree Collapse file tree 1 file changed +25
-8
lines changed Expand file tree Collapse file tree 1 file changed +25
-8
lines changed Original file line number Diff line number Diff line change @@ -3480,15 +3480,32 @@ export class CommandCenter {
34803480 return ;
34813481 }
34823482
3483- // Check whether the selected branch is checked out in an existing worktree
3484- const worktree = repository . worktrees . find ( worktree => worktree . ref === choice . refId ) ;
3485- if ( worktree ) {
3486- const message = l10n . t ( 'Branch "{0}" is already checked out in the worktree at "{1}".' , choice . refName , worktree . path ) ;
3487- await this . handleWorktreeConflict ( worktree . path , message ) ;
3488- return ;
3489- }
3483+ if ( choice . refName === repository . HEAD ?. name ) {
3484+ const message = l10n . t ( 'Branch "{0}" is already checked out in the current repository.' , choice . refName ) ;
3485+ const createBranch = l10n . t ( 'Create New Branch' ) ;
3486+ const pick = await window . showWarningMessage ( message , { modal : true } , createBranch ) ;
3487+
3488+ if ( pick === createBranch ) {
3489+ branch = await this . promptForBranchName ( repository ) ;
34903490
3491- commitish = choice . refName ;
3491+ if ( ! branch ) {
3492+ return ;
3493+ }
3494+
3495+ commitish = 'HEAD' ;
3496+ } else {
3497+ return ;
3498+ }
3499+ } else {
3500+ // Check whether the selected branch is checked out in an existing worktree
3501+ const worktree = repository . worktrees . find ( worktree => worktree . ref === choice . refId ) ;
3502+ if ( worktree ) {
3503+ const message = l10n . t ( 'Branch "{0}" is already checked out in the worktree at "{1}".' , choice . refName , worktree . path ) ;
3504+ await this . handleWorktreeConflict ( worktree . path , message ) ;
3505+ return ;
3506+ }
3507+ commitish = choice . refName ;
3508+ }
34923509 }
34933510
34943511 const worktreeName = ( ( branch ?? commitish ) . startsWith ( branchPrefix )
You can’t perform that action at this time.
0 commit comments