# shellcheck shell=bash

cmd_status() {
    local root; root="$(git_require_repo_root)" || return 1
    
    local here; here="$(git_current_path)"
    local rel="$here"
    [[ "$here" == "$root" ]] && rel="."
    [[ "$here" == "$root"/* ]] && rel="${here#$root/}"
    
    local branch; branch="$(git_current_branch)"
    if [[ -z "$branch" ]]; then
        branch="$(git_current_commit_short)"
        [[ -z "$branch" ]] && { err "Cannot determine branch/commit"; return 1; }
        info "🌳 In worktree '$rel' (Detached HEAD: $branch)"
    else
        info "🌳 In worktree '$rel' on branch '$branch'"
    fi
    echo ""
    git_status "$@"
}
