# shellcheck shell=dash

alias xgp='x git part'

___x_cmd_git_part(){
    [ $# -gt 0 ] ||     set -- ls

    local op="$1";      shift
    case "$op" in
        cl|clone)       ___x_cmd_git_part_clone             "$@"    ;;
        co|checkout)    ___x_cmd_git_part_checkout          "$@"    ;;
        ls)             ___x_cmd_git_part_ls                "$@"    ;;

        add|set)        ___x_cmd_git_part_checkout "$op"    "$@"    ;;

        -h|--help)      ___x_cmd_git___help part; return            ;;
        *)              N=git M="unsupported op ==> $op" log:ret:64 ;;
    esac
}

___x_cmd_git_part_clone(){
    # local x_=;  ___x_cmd_git_clone___repo_ "$1"
    # command git clone --filter=blob:none --sparse "$x_"
    ___x_cmd_git_clone --filter=blob:none --sparse "$@"
}

___x_cmd_git_part_ls(){
    command git ls-tree "${1:-HEAD}"
}

___x_cmd_git_part_checkout(){
    [ $# -gt 0 ] ||     set -- ls

    local op="$1";      shift
    case "$op" in
        ls|list)        command git sparse-checkout list "$@"       ;;
        init|set|add|reapply|disable)
                        command git sparse-checkout "$op" "$@"      ;;

        -h|--help)      ___x_cmd_git___help part checkout; return   ;;
        *)              N=git M="unsupported op in part_checkout ==> $op" log:ret:64;;
    esac
}
