SZEDER Gábor [off-list ref] writes:
On Fri, Sep 28, 2012 at 11:04:05AM -0700, Junio C Hamano wrote:
quoted
SZEDER Gábor [off-list ref] writes:
quoted
To simulate the the user hit 'git <TAB>, one of the completion tests
s/the the/that the/
quoted
quoted
sets up the rather strange command line
git ""
i.e. the second word on the command line consists of two double
quotes. However, this is not what happens for real, because after
'git <TAB>' the second word on the command line is just an empty
string. Luckily, the test works nevertheless.
Fix this by passing the command line to run_completion() as separate
words.
Signed-off-by: SZEDER Gábor <redacted>
---
t/t9902-completion.sh | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/t/t9902-completion.sh b/t/t9902-completion.sh
index e7657537..f5e68834 100755
--- a/t/t9902-completion.sh
+++ b/t/t9902-completion.sh
@@ -49,7 +49,7 @@ run_completion ()
{
local -a COMPREPLY _words
local _cword
- _words=( $1 )
+ _words=( "$@" )
(( _cword = ${#_words[@]} - 1 ))
__git_wrap__git_main && print_comp
}@@ -57,7 +57,7 @@ run_completion ()
test_completion ()
{
test $# -gt 1 && echo "$2" > expected
- run_completion "$@" &&
+ run_completion $1 &&
test_cmp expected out
}
I can understand the other three hunks, but this one is fishy.
Shouldn't "$1" be inside a pair of dq? I.e.
+ run_completion "$1" &&
No. $1 holds all words on the command line. If it was between a pair
of dq, then the whole command line would be passed to the completion
script as a single word.
And these "words" can be split at $IFS boundaries without any
issues? IOW, nobody would ever want to make words array in the
run_completion function to ['git' 'foo bar' 'baz']?
On Fri, Sep 28, 2012 at 12:23:47PM -0700, Junio C Hamano wrote:
quoted
quoted
quoted
@@ -57,7 +57,7 @@ run_completion ()
test_completion ()
{
test $# -gt 1 && echo "$2" > expected
- run_completion "$@" &&
+ run_completion $1 &&
test_cmp expected out
}
I can understand the other three hunks, but this one is fishy.
Shouldn't "$1" be inside a pair of dq? I.e.
+ run_completion "$1" &&
No. $1 holds all words on the command line. If it was between a pair
of dq, then the whole command line would be passed to the completion
script as a single word.
And these "words" can be split at $IFS boundaries without any
issues? IOW, nobody would ever want to make words array in the
run_completion function to ['git' 'foo bar' 'baz']?
It might be simpler to just convert test_completion into the
test_completion_long I added in my series; the latter takes the expected
output on stdin, leaving the actual arguments free to represent the real
command-line. E.g., your example would become:
test_completion git "foo bar" baz <<-\EOF
... expected output ...
EOF
-Peff
On Fri, Sep 28, 2012 at 12:23:47PM -0700, Junio C Hamano wrote:
SZEDER Gábor [off-list ref] writes:
quoted
On Fri, Sep 28, 2012 at 11:04:05AM -0700, Junio C Hamano wrote:
quoted
SZEDER Gábor [off-list ref] writes:
quoted
To simulate the the user hit 'git <TAB>, one of the completion tests
s/the the/that the/
quoted
quoted
sets up the rather strange command line
git ""
i.e. the second word on the command line consists of two double
quotes. However, this is not what happens for real, because after
'git <TAB>' the second word on the command line is just an empty
string. Luckily, the test works nevertheless.
Fix this by passing the command line to run_completion() as separate
words.
Signed-off-by: SZEDER Gábor <redacted>
---
t/t9902-completion.sh | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/t/t9902-completion.sh b/t/t9902-completion.sh
index e7657537..f5e68834 100755
--- a/t/t9902-completion.sh
+++ b/t/t9902-completion.sh
@@ -49,7 +49,7 @@ run_completion ()
{
local -a COMPREPLY _words
local _cword
- _words=( $1 )
+ _words=( "$@" )
(( _cword = ${#_words[@]} - 1 ))
__git_wrap__git_main && print_comp
}@@ -57,7 +57,7 @@ run_completion ()
test_completion ()
{
test $# -gt 1 && echo "$2" > expected
- run_completion "$@" &&
+ run_completion $1 &&
test_cmp expected out
}
I can understand the other three hunks, but this one is fishy.
Shouldn't "$1" be inside a pair of dq? I.e.
+ run_completion "$1" &&
No. $1 holds all words on the command line. If it was between a pair
of dq, then the whole command line would be passed to the completion
script as a single word.
And these "words" can be split at $IFS boundaries without any
issues? IOW, nobody would ever want to make words array in the
run_completion function to ['git' 'foo bar' 'baz']?
Maybe we would, but making it work would be a separate fix. You can't
do that with the current version either.