]> git.ipfire.org Git - thirdparty/git.git/commitdiff
completion: zsh: fix completion for --no-.. options
authorFelipe Contreras <felipe.contreras@gmail.com>
Wed, 28 Oct 2020 02:06:54 +0000 (20:06 -0600)
committerJunio C Hamano <gitster@pobox.com>
Wed, 28 Oct 2020 21:30:59 +0000 (14:30 -0700)
This was introduced in upstream's bash script, but never in zsh's:

  b221b5ab9b (completion: collapse extra --no-.. options)

It has been failing since v2.19.

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
contrib/completion/git-completion.zsh

index f524c6042a26afd0a7ab491e1f1c0273946df3ac..e5670625052b07cdd64401bd7fdfb43460856e26 100644 (file)
@@ -59,10 +59,32 @@ __gitcomp ()
        case "$cur_" in
        --*=)
                ;;
+       --no-*)
+               local c IFS=$' \t\n'
+               local -a array
+               for c in ${=1}; do
+                       if [[ $c == "--" ]]; then
+                               continue
+                       fi
+                       c="$c${4-}"
+                       case $c in
+                       --*=|*.) ;;
+                       *) c="$c " ;;
+                       esac
+                       array+=("$c")
+               done
+               compset -P '*[=:]'
+               compadd -Q -S '' -p "${2-}" -a -- array && _ret=0
+               ;;
        *)
                local c IFS=$' \t\n'
                local -a array
                for c in ${=1}; do
+                       if [[ $c == "--" ]]; then
+                               c="--no-...${4-}"
+                               array+=("$c ")
+                               break
+                       fi
                        c="$c${4-}"
                        case $c in
                        --*=*|*.) ;;