# shellcheck shell=dash

xrc:mod:lib gitconfig           apply

___x_cmd_gitconfig___main(){
    [ -n "$1" ] || set -- "--help"
    local op="$1";  shift
    case "$op" in
        apply|_themehintrequired)
            ___x_cmd_gitconfig_"$op" "$@" ;;
        -h|--help)
            x help -m gitconfig
            return 1 ;;
        *)
            ___x_cmd_gitconfig_apply "$op" "$@" ;;
    esac
}

# shellcheck disable=SC2120


___x_cmd_gitconfig__themehintrequired(){
    local x_=""

    ___x_cmd wsroot_ || return

    ___x_cmd locatefolder_ "$PWD" ".git" || return

    if [ -f "${___X_CMD_WSROOT_}/.x-cmd/git/hook.yml" ]; then
        [ -d "$___X_CMD_ROOT_GDATA/githook/hooks/${___X_CMD_GITHOOK_VERSION-"v0.0.2"}" ] || return 0
        [ -d "${x_}/.git/.x-cmd/hooks/${___X_CMD_GITHOOK_VERSION-"v0.0.2"}" ] || return 0
    fi

    if [ -f "${___X_CMD_WSROOT_}/.x-cmd/git/config.yml" ]; then
        [ -f "${x_}/.git/.x-cmd/.config.apply" ] || return 0
        [ "${x_}/.git/.x-cmd/.config.apply" -ot "${___X_CMD_WSROOT_}/.x-cmd/git/config.yml" ]
        return
    fi

    return 1
}
