]> git.ipfire.org Git - thirdparty/git.git/commitdiff
completion: trivial test improvement
authorFelipe Contreras <felipe.contreras@gmail.com>
Wed, 10 Apr 2013 06:57:51 +0000 (01:57 -0500)
committerJunio C Hamano <gitster@pobox.com>
Fri, 12 Apr 2013 17:44:53 +0000 (10:44 -0700)
Instead of passing a dummy "", let's check if the last character is a
space, and then move the _cword accordingly.

Apparently we were passing "" all the way to compgen, which fortunately
expanded it to nothing.

Lets do the right thing though.

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
t/t9902-completion.sh

index adc1372b3c334b4305761f6c3922493c85a0822a..99d5c0142ffa6174c392cd31e262bce1b7bbe305 100755 (executable)
@@ -69,6 +69,7 @@ run_completion ()
        local -a COMPREPLY _words
        local _cword
        _words=( $1 )
+       test "${1: -1}" == ' ' && _words+=('')
        (( _cword = ${#_words[@]} - 1 ))
        __git_wrap__git_main && print_comp
 }
@@ -148,7 +149,7 @@ test_expect_success '__gitcomp - suffix' '
 '
 
 test_expect_success 'basic' '
-       run_completion "git \"\"" &&
+       run_completion "git " &&
        # built-in
        grep -q "^add \$" out &&
        # script