Re: [RFC/PATCH 5/5] completion: refactor __gitcomp_1

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sat, Nov 17, 2012 at 12:27:40PM +0100, Felipe Contreras wrote:
> On Sat, Nov 17, 2012 at 11:58 AM, SZEDER Gábor <szeder@xxxxxxxxxx> wrote:
> 
> >>  # The following function is based on code from:
> >> @@ -249,10 +246,16 @@ __gitcomp ()
> >>       --*=)
> >>               ;;
> >>       *)
> >> -             local IFS=$'\n'
> >> -             __gitcompadd "$(__gitcomp_1 "${1-}" "${4-}")" "${2-}" "$cur_" ""
> >> +             local c IFS=$' \t\n'
> >> +             for c in ${1-}; do
> >> +                     c=`__gitcomp_1 "$c${4-}"`
> >
> > 1. Backticks.
> > 2. A subshell for every word in the wordlist?
> 
> Fine, lets make it hard for zsh then:

No, it's about keeping it usable.  With this change offering the
approximately 170 commands for 'git help <TAB>' would take more than 4
seconds on Windows.


> --- a/contrib/completion/git-completion.bash
> +++ b/contrib/completion/git-completion.bash
> @@ -56,19 +56,6 @@ __gitdir ()
>         fi
>  }
> 
> -__gitcomp_1 ()
> -{
> -       local c IFS=$' \t\n'
> -       for c in $1; do
> -               c="$c$2"
> -               case $c in
> -               --*=*|*.) ;;
> -               *) c="$c " ;;
> -               esac
> -               printf '%s\n' "$c"
> -       done
> -}
> -
>  # The following function is based on code from:
>  #
>  #   bash_completion - programmable completion functions for bash 3.2+
> @@ -241,12 +228,22 @@ __gitcomp ()
>                 COMPREPLY=()
>                 ;;
>         *)
> -               local IFS=$'\n'
> -               COMPREPLY=($(compgen -P "${2-}" \
> -                       -W "$(__gitcomp_1 "${1-}" "${4-}")" \
> -                       -- "$cur_"))
> +               local c i IFS=$' \t\n'
> +               i=0
> +               for c in ${1-}; do
> +                       c="$c${4-}"
> +                       case $c in
> +                       --*=*|*.) ;;
> +                       *) c="$c " ;;
> +                       esac
> +                       if [[ "$c" = "$cur_"* ]]; then
> +                               (( i++ ))
> +                               COMPREPLY[$i]="${2-}$c"
> +                       fi
> +               done
>                 ;;
>         esac
> +
>  }
> 
>  # Generates completion reply with compgen from newline-separated possible
> 
> -- 
> Felipe Contreras
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]