# (C) 2011-2025 magicant

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

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

function completion/git::tag:arg {

        OPTIONS=( #>#
        "a --annotate; make an unsigned annotated tag"
        "--cleanup:; specify the way the message is cleaned up"
        "--color::; show in color"
        "--column::; columnize output"
        "--contains:; list tags that are ancestors of the specified commit"
        "--create-reflog; enable reflog for the new tag"
        "d --delete; delete tags"
        "e --edit; edit the tag message"
        "F: --file:; specify a file containing the message"
        "f --force; overwrite an existing tag"
        "--format:; specify an output format"
        "i --ignore-case; sort and filter tags case-insensitively"
        "l --list; list tag names that match an operand"
        "u: --local-user:; specify a key to make a GPG-signed tag with"
        "m: --message:; specify the message"
        "--merged:; list tags that are descendants of the specified commit"
        "n::; specify the number of lines of annotation to print"
        "--no-column; print tags line by line"
        "--no-contains:; list tags that are not ancestors of the specified commit"
        "--no-merged:; list tags that are not descendants of the specified commit"
        "--no-sign; don't GPG-sign the tag"
        "--omit-empty; don't print empty items"
        "--points-at:; list tags that point at the specified commit"
        "s --sign; make a GPG-signed tag with the default email address's key"
        "--sort:; sort listed tags"
        "--trailer:; specify token-value pair to append to the message"
        "v --verify; verify the GPG signature of tags"
        ) #<#

        command -f completion//parseoptions -n
        case $ARGOPT in
                (-)
                        command -f completion//completeoptions
                        ;;
                (--cleanup|--color|--column|--format|--sort)
                        command -f completion/git::$ARGOPT:arg
                        ;;
                (--contains)
                        command -f completion/git::completeref
                        ;;
                ('')
                        typeset i=2 nomake=false
                        while [ $i -le ${WORDS[#]} ]; do
                                case ${WORDS[i]} in
                                (--)
                                        i=$((i+1))
                                        break
                                        ;;
                                (--contains|--delete|--list|--merged| \
                                --no-contains|--no-merged|--points-at|--verify)
                                        nomake=true
                                        break
                                        ;;
                                (--*)
                                        i=$((i+1))
                                        ;;
                                (-*[dlv]*)
                                        nomake=true
                                        break
                                        ;;
                                (-?*)
                                        i=$((i+1))
                                        ;;
                                (*)
                                        break
                                        ;;
                                esac
                        done
                        if $nomake || [ $i -gt ${WORDS[#]} ]; then
                                command -f completion/git::completeref --tags
                        else
                                command -f completion/git::completeref
                        fi
                        ;;
        esac

}


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