We correctly handle completion items with spaces just fine,
since we pass the lists around with newline delimiters.
However, we do not handle filenames with shell
metacharacters, as "compgen -W" performs expansion on the
list we give it.

Signed-off-by: Jeff King <p...@peff.net>
---
Actually, these vectors are not strictly correct, as I think ultimately
we would like to return

  'name with spaces'

with quotes.  But this lets us test that at least the basics work, and
we can update the test vectors later.

It would be nice to test completion on a file with an embedded newline
(which will also not work), but I'm not even sure what the result is
supposed to look like, so I couldn't write a sane test case. Since I
don't plan on fixing that anytime soon anyway, I think it's sane to just
leave it until later if somebody actually cares.

 t/t9902-completion.sh | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/t/t9902-completion.sh b/t/t9902-completion.sh
index 2fc833a..cbd0fb6 100755
--- a/t/t9902-completion.sh
+++ b/t/t9902-completion.sh
@@ -269,4 +269,23 @@ test_expect_success '<ref>: completes paths' '
        EOF
 '
 
+test_expect_success 'complete tree filename with spaces' '
+       echo content >"name with spaces" &&
+       git add . &&
+       git commit -m spaces &&
+       test_completion_long "git show HEAD:nam" <<-\EOF
+       name with spaces_
+       EOF
+'
+
+test_expect_failure 'complete tree filename with metacharacters' '
+       echo content >"name with \${meta}" &&
+       git add . &&
+       git commit -m meta &&
+       test_completion_long "git show HEAD:nam" <<-\EOF
+       name with ${meta}_
+       name with spaces_
+       EOF
+'
+
 test_done
-- 
1.7.12.10.g31da6dd

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to