# (C) 2011-2025 magicant

# Completion script for the "git-am" command.
# Supports Git 2.48.1.

function completion/git-am {
        WORDS=(git am "${WORDS[2,-1]}")
        command -f completion//reexecute
}

function completion/git::am:arg {

        OPTIONS=( #>#
        "--allow-empty; create empty commit for message without patch"
        "--abort; abort patching and restore the original branch"
        "--committer-date-is-author-date; use author date for committer date"
        "r --continue --resolved; commit the current index and continue patching"
        "--empty:; specify how to handle messages without a patch"
        "S:: --gpg-sign::; sign commits using GPG"
        "--ignore-date; use committer date for author date"
        "i --interactive"
        "k --keep; use the mail subject intact as the commit message"
        "--keep-cr; don't remove carriage returns at the end of lines"
        "--keep-non-patch; keep bracketed words in subject except [PATCH]"
        "m --message-id; add message-id to commit message"
        "--no-3way; don't try 3-way merge on conflict"
        "--no-gpg-sign; don't sign commits using GPG"
        "--no-keep-cr; remove carriage returns at the end of lines"
        "--no-message-id; don't add message-id to commit message"
        "--no-scissors; cancels the --scissors OPTIONS"
        "--no-utf8; don't convert character encoding"
        "v --no-verify; bypass pre-applypatch and applypatch-msg hooks"
        "--patch-format:; specify patch format"
        "--quoted-cr:; specify how to handle CR in quoted email"
        "q --quiet; print error messages only"
        "--quit; abort patching and keep HEAD and index as is"
        "--resolvemsg:"  # not for command line use
        "--retry; re-apply last conflicting patch"
        "c --scissors; remove lines before a scissors line"
        "--show-current-patch::; show message on conflict"
        "s --signoff; add a \"signed-off-by\" line to the message"
        "--skip; skip the current patch (when restarting an aborted patch)"
        "u --utf8; re-encode the log message into UTF-8"
        ) #<#
        if command -vf completion/git::apply:getopt >/dev/null 2>&1 ||
                        . -AL completion/git-apply; then
                command -f completion/git::apply:getopt am
        fi

        command -f completion//parseoptions
        case $ARGOPT in
                (-)
                        command -f completion//completeoptions
                        ;;
                ('')
                        complete -P "$PREFIX" -f
                        ;;
                (--empty)
                        command -f completion/git::--empty:arg
                        ;;
                (--patch-format)
                        complete -P "$PREFIX" mbox mboxrd stgit stgit-series hg
                        ;;
                (S|--gpg-sign)
                        command -f completion/git::--gpg-sign:arg
                        ;;
                (*)
                        if command -vf completion/git::apply:compopt >/dev/null 2>&1 ||
                                        . -AL completion/git-apply; then
                                command -f completion/git::apply:compopt
                        fi
                        ;;
        esac

}


# vim: set ft=sh ts=8 sts=8 sw=8 et:
