completion: small optimization
authorFelipe Contreras <redacted>
Wed, 10 Apr 2013 06:57:57 +0000 (01:57 -0500)
committerJunio C Hamano <redacted>
Mon, 15 Apr 2013 06:18:58 +0000 (23:18 -0700)
No need to calculate a new $c with a space if we are not going to do
anything it with it.

There should be no functional changes, except that a word "foo " with no
suffixes can't be matched. But $cur cannot have a space at the end
anyway. So it's safe.

Based on the code from SZEDER Gábor.

Signed-off-by: Felipe Contreras <redacted>
Signed-off-by: Junio C Hamano <redacted>
contrib/completion/git-completion.bash

index f38579214fa17aeb2c15c73b6fe0ac5d1bca1de4..6df62c217321b4f66fd230a1b95f2b3cfe2becd2 100644 (file)
@@ -210,11 +210,11 @@ __gitcomp ()
                local c i=0 IFS=$' \t\n'
                for c in $1; do
                        c="$c${4-}"
-                       case $c in
-                       --*=*|*.) ;;
-                       *) c="$c " ;;
-                       esac
                        if [[ $c == "$cur_"* ]]; then
+                               case $c in
+                               --*=*|*.) ;;
+                               *) c="$c " ;;
+                               esac
                                COMPREPLY[i++]="${2-}$c"
                        fi
                done
git clone https://git.99rst.org/PROJECT