#compdef git-absorb

autoload -U is-at-least

_git-absorb() {
    typeset -A opt_args
    typeset -a _arguments_options
    local ret=1

    if is-at-least 5.2; then
        _arguments_options=(-s -S -C)
    else
        _arguments_options=(-s -C)
    fi

    local context curcontext="$curcontext" state line
    _arguments "${_arguments_options[@]}" \
'-b+[Use this commit as the base of the absorb stack]:BASE: ' \
'--base=[Use this commit as the base of the absorb stack]:BASE: ' \
'--gen-completions=[Generate completions]:SHELL:(bash fish nushell zsh powershell elvish)' \
'-m+[Commit message body that is given to all fixup commits]:MESSAGE: ' \
'--message=[Commit message body that is given to all fixup commits]:MESSAGE: ' \
'-n[Don'\''t make any actual changes]' \
'--dry-run[Don'\''t make any actual changes]' \
'--force-author[Generate fixups to commits not made by you]' \
'--force-detach[Generate fixups even when on a non-branch (detached) HEAD]' \
'-f[Skip all safety checks as if all --force-* flags were given]' \
'--force[Skip all safety checks as if all --force-* flags were given]' \
'-v[Display more output]' \
'--verbose[Display more output]' \
'-r[Run rebase if successful]' \
'--and-rebase[Run rebase if successful]' \
'-w[Match the change against the complete file]' \
'--whole-file[Match the change against the complete file]' \
'-F[Only generate one fixup per commit]' \
'--one-fixup-per-commit[Only generate one fixup per commit]' \
'-h[Print help]' \
'--help[Print help]' \
'-V[Print version]' \
'--version[Print version]' \
'*::rebase_options -- Extra arguments to pass to git rebase. Only valid if --and-rebase is set:' \
&& ret=0
}

(( $+functions[_git-absorb_commands] )) ||
_git-absorb_commands() {
    local commands; commands=()
    _describe -t commands 'git-absorb commands' commands "$@"
}

if [ "$funcstack[1]" = "_git-absorb" ]; then
    _git-absorb "$@"
else
    compdef _git-absorb git-absorb
fi
