# shellcheck shell=dash

# if lack of prefix, complete the prefix

xrc:mod:lib     git     subtree/main

___x_cmd_git_subtree(){
    [ $# -gt 0 ] || {   ___x_cmd_git___help subtree; return ;   }

    local op="$1";  shift
    case "$op" in
        -h|--help)  ___x_cmd_git___help subtree; return ;;
        ls|hls)     ___x_cmd_git_subtree_hls ;;
        *)          ___x_cmd_git_subtree_origin "$op" "$@" ;;
    esac
}

___x_cmd_git_subtree_origin(){(
    ___x_cmd_inner_cd "$(x git meta root)" || {
        git:error "Not a git repository ==> $PWD"
        return 1
    }
    ___x_cmd___git_origin subtree "$@"
)}

___x_cmd_git_subtree_hls(){
    command git log | command grep git-subtree-dir | ___x_cmd_cmds_awk '{ print $2 }' | command uniq
}

