#!/bin/bash

# shellcheck shell=bash

# Delete worktree only
bridge_delete_worktree_only() {
  if [[ -z "${1:-}" ]]; then
    json_error "Branch name required"
    return 1
  fi
  branch_name="$1"
  
  if git_require_repo_root >/dev/null 2>&1; then
    worktree_path="$(git_branch_to_worktree_path "$branch_name")"
    if [[ -n "$worktree_path" ]]; then
      git_remove_worktree "$worktree_path"
      echo "true"
    else
      json_error "No worktree found for branch: $branch_name"
    fi
  else
    json_error "Not a git repository"
  fi
}
