@@ -398,7 +398,8 @@ fn search_worktrees_internal(manager: &GitWorktreeManager) -> Result<bool> {
398398/// - Custom path: User-specified relative path (e.g., `../custom/path`)
399399/// 3. **Branch Selection**:
400400/// - Create from current HEAD
401- /// - Create from existing branch (shows branch list)
401+ /// - Select branch (shows local/remote branch list)
402+ /// - Select tag (shows tag list)
402403/// 4. **Creation**: Creates the worktree with progress indication
403404/// 5. **File Copy**: Copies configured files (e.g., `.env`) from main worktree
404405/// 6. **Post-create Hooks**: Executes any configured post-create hooks
@@ -581,7 +582,7 @@ fn create_worktree_internal(manager: &GitWorktreeManager) -> Result<bool> {
581582
582583 // Branch handling
583584 println ! ( ) ;
584- let branch_options = vec ! [ "Create from current HEAD" , "Select branch (smart mode) " ] ;
585+ let branch_options = vec ! [ "Create from current HEAD" , "Select branch" , "Select tag "] ;
585586
586587 let branch_choice = match Select :: with_theme ( & get_theme ( ) )
587588 . with_prompt ( "Select branch option" )
@@ -594,7 +595,7 @@ fn create_worktree_internal(manager: &GitWorktreeManager) -> Result<bool> {
594595
595596 let ( branch, new_branch_name) = match branch_choice {
596597 1 => {
597- // Select branch (smart mode)
598+ // Select branch
598599 let ( local_branches, remote_branches) = manager. list_all_branches ( ) ?;
599600 if local_branches. is_empty ( ) && remote_branches. is_empty ( ) {
600601 utils:: print_warning ( "No branches found, creating from HEAD" ) ;
@@ -632,7 +633,7 @@ fn create_worktree_internal(manager: &GitWorktreeManager) -> Result<bool> {
632633 println ! ( ) ;
633634
634635 // Use FuzzySelect for better search experience when there are many branches
635- let selection_result = if branch_items. len ( ) > 10 {
636+ let selection_result = if branch_items. len ( ) > 5 {
636637 println ! ( "Type to search branches (fuzzy search enabled):" ) ;
637638 FuzzySelect :: with_theme ( & get_theme ( ) )
638639 . with_prompt ( "Select a branch" )
@@ -785,6 +786,58 @@ fn create_worktree_internal(manager: &GitWorktreeManager) -> Result<bool> {
785786 }
786787 }
787788 }
789+ 2 => {
790+ // Select tag
791+ let tags = manager. list_all_tags ( ) ?;
792+ if tags. is_empty ( ) {
793+ utils:: print_warning ( "No tags found, creating from HEAD" ) ;
794+ ( None , None )
795+ } else {
796+ // Create items for tag selection with message preview
797+ let tag_items: Vec < String > = tags
798+ . iter ( )
799+ . map ( |( name, message) | {
800+ if let Some ( msg) = message {
801+ // Truncate message to first line for display
802+ let first_line = msg. lines ( ) . next ( ) . unwrap_or ( "" ) ;
803+ let truncated = if first_line. len ( ) > 50 {
804+ format ! ( "{}..." , & first_line[ ..50 ] )
805+ } else {
806+ first_line. to_string ( )
807+ } ;
808+ format ! ( "🏷️ {name} - {truncated}" )
809+ } else {
810+ format ! ( "🏷️ {name}" )
811+ }
812+ } )
813+ . collect ( ) ;
814+
815+ println ! ( ) ;
816+
817+ // Use FuzzySelect for better search experience when there are many tags
818+ let selection_result = if tag_items. len ( ) > 5 {
819+ println ! ( "Type to search tags (fuzzy search enabled):" ) ;
820+ FuzzySelect :: with_theme ( & get_theme ( ) )
821+ . with_prompt ( "Select a tag" )
822+ . items ( & tag_items)
823+ . interact_opt ( ) ?
824+ } else {
825+ Select :: with_theme ( & get_theme ( ) )
826+ . with_prompt ( "Select a tag" )
827+ . items ( & tag_items)
828+ . interact_opt ( ) ?
829+ } ;
830+
831+ match selection_result {
832+ Some ( selection) => {
833+ let selected_tag = & tags[ selection] . 0 ;
834+ // For tags, we always create a new branch named after the worktree
835+ ( Some ( selected_tag. clone ( ) ) , Some ( name. clone ( ) ) )
836+ }
837+ None => return Ok ( false ) ,
838+ }
839+ }
840+ }
788841 _ => {
789842 // Create from current HEAD
790843 ( None , None )
@@ -800,10 +853,22 @@ fn create_worktree_internal(manager: &GitWorktreeManager) -> Result<bool> {
800853 println ! ( " {name_label} {name_value}" ) ;
801854 if let Some ( new_branch) = & new_branch_name {
802855 let base_branch_name = branch. as_ref ( ) . unwrap ( ) ;
803- let branch_label = "New Branch:" . bright_black ( ) ;
804- let branch_value = new_branch. yellow ( ) ;
805- let base_value = base_branch_name. bright_black ( ) ;
806- println ! ( " {branch_label} {branch_value} (from {base_value})" ) ;
856+ // Check if the base branch is a tag
857+ if manager
858+ . repo ( )
859+ . find_reference ( & format ! ( "refs/tags/{base_branch_name}" ) )
860+ . is_ok ( )
861+ {
862+ let branch_label = "New Branch:" . bright_black ( ) ;
863+ let branch_value = new_branch. yellow ( ) ;
864+ let tag_value = format ! ( "tag: {base_branch_name}" ) . bright_cyan ( ) ;
865+ println ! ( " {branch_label} {branch_value} (from {tag_value})" ) ;
866+ } else {
867+ let branch_label = "New Branch:" . bright_black ( ) ;
868+ let branch_value = new_branch. yellow ( ) ;
869+ let base_value = base_branch_name. bright_black ( ) ;
870+ println ! ( " {branch_label} {branch_value} (from {base_value})" ) ;
871+ }
807872 } else if let Some ( branch_name) = & branch {
808873 let branch_label = "Branch:" . bright_black ( ) ;
809874 let branch_value = branch_name. yellow ( ) ;
0 commit comments