Re: [PATCH 01/11] t9902-completion: add tests demonstrating issues with quoted pathnames

2018-04-25 Thread Junio C Hamano
SZEDER Gábor  writes:

> These new tests, however, are primarily interested in the inner
> workings of __git_complete_index_file() in the presence of escapes
> and/or quotes in the path to be completed and/or in the output of 'git
> ls-files'.  For these kind of tests we could simply invoke
> __git_complete_index_file() directly, like we call __git_refs()
> directly to test refs completion.  Then we could set the current path
> to be completed to whatever we want, including spaces, because it
> won't be subject to field splitting like the command line given to
> 'test_completion'.
>
> So, I think for v2 I will rewrite these tests to call
> __git_complete_index_file() directly instead of using
> 'test_completion', and will include a test with spaces in path names.

Quite well thought-out reasoning.  Thanks.


Re: [PATCH 01/11] t9902-completion: add tests demonstrating issues with quoted pathnames

2018-04-25 Thread SZEDER Gábor
On Wed, Apr 18, 2018 at 3:22 AM, Junio C Hamano  wrote:
> SZEDER Gábor  writes:
>>> Do we want to test a more common case of a filename that is two
>>> words with SP in between, i.e.
>>>
>>> $ >'hello world' && git add hel
>>>
>>> or is it known to work just fine without quoting/escaping (because
>>> the funny we care about is output from ls-files and SP is not special
>>> in its one-item-at-a-time-on-a-line output) and not worth checking?
>>
>> This particular case already works, even without this patch series.
>
> I was more wondering about preventing regressions---"it worked
> without this patch series, but now it is broken" is what I was
> worried about.
>
>> The problems start when you want to complete the filename after a space,
>> e.g. 'hello\ w> was the first thing I tried to write a test for, but it didn't work out:
>> inside the 'test_completion' helper function the space acts as
>> separator, and the completion script then sees 'hello\' and 'w' as two
>> separate words.
>
> Hmph.  That is somewhat unfortunate.

Actually, I used 'test_completion' in these new tests, because there
is that big test checking file completion for various commands, and it
already uses 'test_completion', so I just followed suit.  Now, that
test checks that the right type(s) of files are listed for various git
commands, e.g. modified and untracked for 'git add', IOW that the
caller of __git_complete_index_file() specifies the appropriate 'git
ls-files' options.  For those kind of checks 'test_completion' is
great.

These new tests, however, are primarily interested in the inner
workings of __git_complete_index_file() in the presence of escapes
and/or quotes in the path to be completed and/or in the output of 'git
ls-files'.  For these kind of tests we could simply invoke
__git_complete_index_file() directly, like we call __git_refs()
directly to test refs completion.  Then we could set the current path
to be completed to whatever we want, including spaces, because it
won't be subject to field splitting like the command line given to
'test_completion'.

So, I think for v2 I will rewrite these tests to call
__git_complete_index_file() directly instead of using
'test_completion', and will include a test with spaces in path names.


Re: [PATCH 01/11] t9902-completion: add tests demonstrating issues with quoted pathnames

2018-04-19 Thread SZEDER Gábor
On Wed, Apr 18, 2018 at 2:31 PM, Johannes Schindelin
 wrote:

> I suspect that the culprit is once again Cygwin's trick where illegal
> characters are mapped into a private Unicode page. Cygwin (and therefore
> MSYS2 runtime, and therefore the Bash used to run the test script) can use
> those filenames all right, but Git cannot.
>
> So even testing whether you could write an illegal file name via shell
> script is *not* enough to determine whether the file system supports funny
> characters.

I followed suit of all existing FUNNYNAMES checks:

  $ git grep -B3 'test_set_prereq FUNNYNAMES' master t/
  master:t/t3600-rm.sh-if test_have_prereq !MINGW && touch -- 'tab
   embedded' 'newline
  master:t/t3600-rm.sh-embedded' 2>/dev/null
  master:t/t3600-rm.sh-then
  master:t/t3600-rm.sh:   test_set_prereq FUNNYNAMES
  --
  master:t/t4135-apply-weird-filenames.sh-if test_have_prereq !MINGW &&
  master:t/t4135-apply-weird-filenames.sh-touch --
"tab   embedded.txt" '\''"quoteembedded".txt'\''
  master:t/t4135-apply-weird-filenames.sh-then
  master:t/t4135-apply-weird-filenames.sh:
test_set_prereq FUNNYNAMES
  --
  master:t/t9903-bash-prompt.sh-
  master:t/t9903-bash-prompt.sh-if test_have_prereq !MINGW && mkdir
"$repo_with_newline" 2>/dev/null
  master:t/t9903-bash-prompt.sh-then
  master:t/t9903-bash-prompt.sh:  test_set_prereq FUNNYNAMES

How am I supposed to check this, then?


> As far as I can tell from a *really* cursory glance, this is the only
> affected test case. Apparently your prereq catches, somehow, on Windows:
>
> 2018-04-18T11:12:43.0459702Z Your filesystem does not allow \ and " in 
> filenames.
> 2018-04-18T11:12:43.0459823Z skipped: complete files - C-style escapes in 
> ls-files output (missing FUNNYNAMES_BS_DQ)


Re: [PATCH 01/11] t9902-completion: add tests demonstrating issues with quoted pathnames

2018-04-18 Thread Johannes Schindelin
Hi Gábor,

On Tue, 17 Apr 2018, SZEDER Gábor wrote:

> Completion functions see all words on the command line verbatim,
> including any backslash-escapes, single and double quotes that might
> be there.  Furthermore, git commands quote pathnames if they contain
> certain special characters.  All these create various issues when
> doing git-aware path completion.
> 
> Add a couple of failing tests to demonstrate these issues.
> 
> Later patches in this series will discuss these issues in detail as
> they fix them.
> 
> Signed-off-by: SZEDER Gábor 
> ---
> 
> Notes:
> Do any more new tests need FUNNYNAMES* prereq?

Yes.

>  t/t9902-completion.sh | 91 +++
>  1 file changed, 91 insertions(+)
> 
> diff --git a/t/t9902-completion.sh b/t/t9902-completion.sh
> index b7f5b1e632..ff2e4a8f5f 100755
> --- a/t/t9902-completion.sh
> +++ b/t/t9902-completion.sh
> @@ -1427,6 +1427,97 @@ test_expect_success 'complete files' '
>   test_completion "git add mom" "momified"
>  '
>  
> +# The next tests only care about how the completion script deals with
> +# unusual characters in path names.  By defining a custom completion
> +# function to list untracked files they won't be influenced by future
> +# changes of the completion functions of real git commands, and we
> +# don't have to bother with adding files to the index in these tests.
> +_git_test_path_comp ()
> +{
> + __git_complete_index_file --others
> +}
> +
> +test_expect_failure 'complete files - escaped characters on cmdline' '
> + test_when_finished "rm -rf \"New|Dir\"" &&
> + mkdir "New|Dir" &&
> + >"New|Dir/New" &&
> +
> + test_completion "git test-path-comp N" \
> + "New|Dir" &&# Bash will turn this into "New\|Dir/"
> + test_completion "git test-path-comp New\\|D" \
> + "New|Dir" &&
> + test_completion "git test-path-comp New\\|Dir/N" \
> + "New|Dir/New" && # Bash will turn this into
> + # "New\|Dir/New\ "
> + test_completion "git test-path-comp New\\|Dir/New\\" \
> + "New|Dir/New"
> +'

This fails with:

2018-04-18T11:12:55.0436371Z expecting success: 
2018-04-18T11:12:55.0436665Ztest_when_finished "rm -rf \"New|Dir\"" &&
2018-04-18T11:12:55.0436799Zmkdir "New|Dir" &&
2018-04-18T11:12:55.0436904Z>"New|Dir/New" &&
2018-04-18T11:12:55.0436972Z 
2018-04-18T11:12:55.0437158Ztest_completion "git test-path-comp N" \
2018-04-18T11:12:55.0437296Z"New|Dir" &&# Bash will 
turn this into "New\|Dir/"
2018-04-18T11:12:55.0437413Ztest_completion "git test-path-comp New\\|D" \
2018-04-18T11:12:55.0437522Z"New|Dir" &&
2018-04-18T11:12:55.0437629Ztest_completion "git test-path-comp 
New\\|Dir/N" \
2018-04-18T11:12:55.0437767Z"New|Dir/New" && # Bash 
will turn this into
2018-04-18T11:12:55.0438040Z# 
"New\|Dir/New\ "
2018-04-18T11:12:55.0438152Ztest_completion "git test-path-comp 
New\\|Dir/New\\" \
2018-04-18T11:12:55.0438504Z"New|Dir/New"
2018-04-18T11:12:55.0438742Z 
2018-04-18T11:12:55.0590984Z ++ test_when_finished 'rm -rf "New|Dir"'
2018-04-18T11:12:55.0591722Z ++ test 0 = 0
2018-04-18T11:12:55.0592001Z ++ test_cleanup='{ rm -rf "New|Dir"
2018-04-18T11:12:55.0592290Z} && (exit "$eval_ret"); eval_ret=$?; :'
2018-04-18T11:12:55.0592472Z ++ mkdir 'New|Dir'
2018-04-18T11:12:55.0717255Z ++ test_completion 'git test-path-comp N' 'New|Dir'
2018-04-18T11:12:55.0717680Z ++ test 2 -gt 1
2018-04-18T11:12:55.0718062Z ++ printf '%s\n' 'New|Dir'
2018-04-18T11:12:55.0718275Z ++ run_completion 'git test-path-comp N'
2018-04-18T11:12:55.0718447Z ++ local -a COMPREPLY _words
2018-04-18T11:12:55.0718631Z ++ local _cword
2018-04-18T11:12:55.0718806Z ++ _words=($1)
2018-04-18T11:12:55.0718965Z ++ test N = ' '
2018-04-18T11:12:55.0719124Z ++ ((  _cword = 3 - 1  ))
2018-04-18T11:12:55.0719286Z ++ __git_wrap__git_main
2018-04-18T11:12:55.0719467Z ++ __git_func_wrap __git_main
2018-04-18T11:12:55.0719633Z ++ local cur words cword prev
2018-04-18T11:12:55.0719801Z ++ _get_comp_words_by_ref -n =: cur words cword 
prev
2018-04-18T11:12:55.0720074Z ++ '[' 6 -gt 0 ']'
2018-04-18T11:12:55.0720239Z ++ case "$1" in
2018-04-18T11:12:55.0720406Z ++ shift
2018-04-18T11:12:55.0720584Z ++ '[' 5 -gt 0 ']'
2018-04-18T11:12:55.0720742Z ++ case "$1" in
2018-04-18T11:12:55.0720899Z ++ shift
2018-04-18T11:12:55.0721054Z ++ '[' 4 -gt 0 ']'
2018-04-18T11:12:55.0721240Z ++ case "$1" in
2018-04-18T11:12:55.0721392Z ++ cur=N
2018-04-18T11:12:55.0721547Z ++ shift
2018-04-18T11:12:55.0721717Z ++ '[' 3 -gt 0 ']'
2018-04-18T11:12:55.0721879Z ++ case "$1" in
2018-04-18T11:12:55.0722040Z ++ words=("${_words[@]}")
2018-04-18T11:12:55.0722201Z ++ shift
2018-04-18T11:12:55.0722396Z ++ '[' 2 -gt 0 ']'
2018-04-18T11:12:55.0722931Z ++ case 

Re: [PATCH 01/11] t9902-completion: add tests demonstrating issues with quoted pathnames

2018-04-17 Thread Junio C Hamano
SZEDER Gábor  writes:

>>> +test_expect_failure 'complete files - quoted characters on cmdline' '
>>> + test_when_finished "rm -r \"New(Dir\"" &&
>>
>> This does not use -rf unlike the previous one?
>
> Noted.
>
> The lack of '-f' is leftover from early versions of these tests, when I
> had a hard time getting the quoting-escaping right.  Without the '-f'
> 'rm' errored out when I messed up, and the error message helpfully
> contained the path it wasn't able to delete.

Sounds like we do not want 'f' from both tests, then?  I think it is
OK either way.

>>> +if test_have_prereq !MINGW &&
>>> +   mkdir $'New\034Special\035Dir' 2>/dev/null &&
>>> +   touch $'New\034Special\035Dir/New\036Special\037File' 2>/dev/null
>>
>> The $'...' quote is bash-ism, but this is about testing bash
>> completion, so as long as we make sure non-bash shells won't touch
>> this part of the test, it is OK.
>>
>> Do we want to test a more common case of a filename that is two
>> words with SP in between, i.e.
>>
>> $ >'hello world' && git add hel
>>
>> or is it known to work just fine without quoting/escaping (because
>> the funny we care about is output from ls-files and SP is not special
>> in its one-item-at-a-time-on-a-line output) and not worth checking?
>
> This particular case already works, even without this patch series.

I was more wondering about preventing regressions---"it worked
without this patch series, but now it is broken" is what I was
worried about.

> The problems start when you want to complete the filename after a space,
> e.g. 'hello\ w was the first thing I tried to write a test for, but it didn't work out:
> inside the 'test_completion' helper function the space acts as
> separator, and the completion script then sees 'hello\' and 'w' as two
> separate words.

Hmph.  That is somewhat unfortunate.


Re: [PATCH 01/11] t9902-completion: add tests demonstrating issues with quoted pathnames

2018-04-17 Thread SZEDER Gábor
On Wed, Apr 18, 2018 at 1:32 AM, SZEDER Gábor  wrote:
> On Tue, Apr 17, 2018 at 5:48 AM, Junio C Hamano  wrote:
>> SZEDER Gábor  writes:
>>
>>> Do any more new tests need FUNNYNAMES* prereq?
>>
>> Hmph, all of these look like they involve some funnynames ;-)
>
> Well, I can' create a directory with a '|' in its name on FAT32 (on
> Linux), so this needs FUNNYNAMES prereq, too.

Or, on second thought, using a different, more widely usable character
would be better, so the test can be run on more platforms.


>> Do we want to test a more common case of a filename that is two
>> words with SP in between, i.e.
>>
>> $ >'hello world' && git add hel
>>
>> or is it known to work just fine without quoting/escaping (because
>> the funny we care about is output from ls-files and SP is not special
>> in its one-item-at-a-time-on-a-line output) and not worth checking?
>
> This particular case already works, even without this patch series.
>
> The problems start when you want to complete the filename after a space,
> e.g. 'hello\ w was the first thing I tried to write a test for, but it didn't work out:
> inside the 'test_completion' helper function the space acts as
> separator, and the completion script then sees 'hello\' and 'w' as two
> separate words.

On another second thought, a test for the already working 'hel'
case could make sure that we won't mess up the value of IFS when filling
COMPREPLY.


Re: [PATCH 01/11] t9902-completion: add tests demonstrating issues with quoted pathnames

2018-04-17 Thread SZEDER Gábor
On Tue, Apr 17, 2018 at 5:48 AM, Junio C Hamano  wrote:
> SZEDER Gábor  writes:
>
>> Do any more new tests need FUNNYNAMES* prereq?
>
> Hmph, all of these look like they involve some funnynames ;-)

Well, I can' create a directory with a '|' in its name on FAT32 (on
Linux), so this needs FUNNYNAMES prereq, too.

>> +test_expect_failure 'complete files - escaped characters on cmdline' '
>> + test_when_finished "rm -rf \"New|Dir\"" &&
>> + mkdir "New|Dir" &&
>> + >"New|Dir/New" &&
>> +
>> + test_completion "git test-path-comp N" \
>> + "New|Dir" &&# Bash will turn this into "New\|Dir/"
>> + test_completion "git test-path-comp New\\|D" \
>> + "New|Dir" &&
>> + test_completion "git test-path-comp New\\|Dir/N" \
>> + "New|Dir/New" && # Bash will turn this into
>> + # "New\|Dir/New\ "
>> + test_completion "git test-path-comp New\\|Dir/New\\" \
>> + "New|Dir/New"
>> +'
>> +
>> +test_expect_failure 'complete files - quoted characters on cmdline' '
>> + test_when_finished "rm -r \"New(Dir\"" &&
>
> This does not use -rf unlike the previous one?

Noted.

The lack of '-f' is leftover from early versions of these tests, when I
had a hard time getting the quoting-escaping right.  Without the '-f'
'rm' errored out when I messed up, and the error message helpfully
contained the path it wasn't able to delete.

>> + mkdir "New(Dir" &&
>> + >"New(Dir/New)File.c" &&
>> +
>> + test_completion "git test-path-comp \"New(D" "New(Dir" &&
>> + test_completion "git test-path-comp \"New(Dir/New)F" \
>> + "New(Dir/New)File.c"
>> +'
>
> OK.
>
>> +test_expect_failure 'complete files - UTF-8 in ls-files output' '
>> + test_when_finished "rm -r árvíztűrő" &&
>> + mkdir árvíztűrő &&
>> + >"árvíztűrő/Сайн яваарай" &&
>> +
>> + test_completion "git test-path-comp á" "árvíztűrő" &&
>> + test_completion "git test-path-comp árvíztűrő/С" \
>> + "árvíztűrő/Сайн яваарай"
>> +'
>> +
>> +if test_have_prereq !MINGW &&
>> +   mkdir 'New\Dir' 2>/dev/null &&
>> +   touch 'New\Dir/New"File.c' 2>/dev/null
>> +then
>> + test_set_prereq FUNNYNAMES_BS_DQ
>> +else
>> + say "Your filesystem does not allow \\ and \" in filenames."
>> + rm -rf 'New\Dir'
>> +fi
>> +test_expect_failure FUNNYNAMES_BS_DQ \
>> +'complete files - C-style escapes in ls-files output' '
>> + test_when_finished "rm -r \"NewDir\"" &&
>> +
>> + test_completion "git test-path-comp N" "New\\Dir" &&
>> + test_completion "git test-path-comp NewD" "New\\Dir" &&
>> + test_completion "git test-path-comp NewDir/N" \
>> + "New\\Dir/New\"File.c" &&
>> + test_completion "git test-path-comp NewDir/New\\\"F" \
>> + "New\\Dir/New\"File.c"
>> +'
>> +
>> +if test_have_prereq !MINGW &&
>> +   mkdir $'New\034Special\035Dir' 2>/dev/null &&
>> +   touch $'New\034Special\035Dir/New\036Special\037File' 2>/dev/null
>
> The $'...' quote is bash-ism, but this is about testing bash
> completion, so as long as we make sure non-bash shells won't touch
> this part of the test, it is OK.
>
> Do we want to test a more common case of a filename that is two
> words with SP in between, i.e.
>
> $ >'hello world' && git add hel
>
> or is it known to work just fine without quoting/escaping (because
> the funny we care about is output from ls-files and SP is not special
> in its one-item-at-a-time-on-a-line output) and not worth checking?

This particular case already works, even without this patch series.

The problems start when you want to complete the filename after a space,
e.g. 'hello\ w

Re: [PATCH 01/11] t9902-completion: add tests demonstrating issues with quoted pathnames

2018-04-16 Thread Junio C Hamano
SZEDER Gábor  writes:

> Do any more new tests need FUNNYNAMES* prereq?

Hmph, all of these look like they involve some funnynames ;-)

> +test_expect_failure 'complete files - escaped characters on cmdline' '
> + test_when_finished "rm -rf \"New|Dir\"" &&
> + mkdir "New|Dir" &&
> + >"New|Dir/New" &&
> +
> + test_completion "git test-path-comp N" \
> + "New|Dir" &&# Bash will turn this into "New\|Dir/"
> + test_completion "git test-path-comp New\\|D" \
> + "New|Dir" &&
> + test_completion "git test-path-comp New\\|Dir/N" \
> + "New|Dir/New" && # Bash will turn this into
> + # "New\|Dir/New\ "
> + test_completion "git test-path-comp New\\|Dir/New\\" \
> + "New|Dir/New"
> +'
> +
> +test_expect_failure 'complete files - quoted characters on cmdline' '
> + test_when_finished "rm -r \"New(Dir\"" &&

This does not use -rf unlike the previous one?

> + mkdir "New(Dir" &&
> + >"New(Dir/New)File.c" &&
> +
> + test_completion "git test-path-comp \"New(D" "New(Dir" &&
> + test_completion "git test-path-comp \"New(Dir/New)F" \
> + "New(Dir/New)File.c"
> +'

OK.

> +test_expect_failure 'complete files - UTF-8 in ls-files output' '
> + test_when_finished "rm -r árvíztűrő" &&
> + mkdir árvíztűrő &&
> + >"árvíztűrő/Сайн яваарай" &&
> +
> + test_completion "git test-path-comp á" "árvíztűrő" &&
> + test_completion "git test-path-comp árvíztűrő/С" \
> + "árvíztűrő/Сайн яваарай"
> +'
> +
> +if test_have_prereq !MINGW &&
> +   mkdir 'New\Dir' 2>/dev/null &&
> +   touch 'New\Dir/New"File.c' 2>/dev/null
> +then
> + test_set_prereq FUNNYNAMES_BS_DQ
> +else
> + say "Your filesystem does not allow \\ and \" in filenames."
> + rm -rf 'New\Dir'
> +fi
> +test_expect_failure FUNNYNAMES_BS_DQ \
> +'complete files - C-style escapes in ls-files output' '
> + test_when_finished "rm -r \"NewDir\"" &&
> +
> + test_completion "git test-path-comp N" "New\\Dir" &&
> + test_completion "git test-path-comp NewD" "New\\Dir" &&
> + test_completion "git test-path-comp NewDir/N" \
> + "New\\Dir/New\"File.c" &&
> + test_completion "git test-path-comp NewDir/New\\\"F" \
> + "New\\Dir/New\"File.c"
> +'
> +
> +if test_have_prereq !MINGW &&
> +   mkdir $'New\034Special\035Dir' 2>/dev/null &&
> +   touch $'New\034Special\035Dir/New\036Special\037File' 2>/dev/null

The $'...' quote is bash-ism, but this is about testing bash
completion, so as long as we make sure non-bash shells won't touch
this part of the test, it is OK.

Do we want to test a more common case of a filename that is two
words with SP in between, i.e. 

$ >'hello world' && git add hel

or is it known to work just fine without quoting/escaping (because
the funny we care about is output from ls-files and SP is not special
in its one-item-at-a-time-on-a-line output) and not worth checking?


[PATCH 01/11] t9902-completion: add tests demonstrating issues with quoted pathnames

2018-04-16 Thread SZEDER Gábor
Completion functions see all words on the command line verbatim,
including any backslash-escapes, single and double quotes that might
be there.  Furthermore, git commands quote pathnames if they contain
certain special characters.  All these create various issues when
doing git-aware path completion.

Add a couple of failing tests to demonstrate these issues.

Later patches in this series will discuss these issues in detail as
they fix them.

Signed-off-by: SZEDER Gábor 
---

Notes:
Do any more new tests need FUNNYNAMES* prereq?

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

diff --git a/t/t9902-completion.sh b/t/t9902-completion.sh
index b7f5b1e632..ff2e4a8f5f 100755
--- a/t/t9902-completion.sh
+++ b/t/t9902-completion.sh
@@ -1427,6 +1427,97 @@ test_expect_success 'complete files' '
test_completion "git add mom" "momified"
 '
 
+# The next tests only care about how the completion script deals with
+# unusual characters in path names.  By defining a custom completion
+# function to list untracked files they won't be influenced by future
+# changes of the completion functions of real git commands, and we
+# don't have to bother with adding files to the index in these tests.
+_git_test_path_comp ()
+{
+   __git_complete_index_file --others
+}
+
+test_expect_failure 'complete files - escaped characters on cmdline' '
+   test_when_finished "rm -rf \"New|Dir\"" &&
+   mkdir "New|Dir" &&
+   >"New|Dir/New" &&
+
+   test_completion "git test-path-comp N" \
+   "New|Dir" &&# Bash will turn this into "New\|Dir/"
+   test_completion "git test-path-comp New\\|D" \
+   "New|Dir" &&
+   test_completion "git test-path-comp New\\|Dir/N" \
+   "New|Dir/New" && # Bash will turn this into
+   # "New\|Dir/New\ "
+   test_completion "git test-path-comp New\\|Dir/New\\" \
+   "New|Dir/New"
+'
+
+test_expect_failure 'complete files - quoted characters on cmdline' '
+   test_when_finished "rm -r \"New(Dir\"" &&
+   mkdir "New(Dir" &&
+   >"New(Dir/New)File.c" &&
+
+   test_completion "git test-path-comp \"New(D" "New(Dir" &&
+   test_completion "git test-path-comp \"New(Dir/New)F" \
+   "New(Dir/New)File.c"
+'
+
+test_expect_failure 'complete files - UTF-8 in ls-files output' '
+   test_when_finished "rm -r árvíztűrő" &&
+   mkdir árvíztűrő &&
+   >"árvíztűrő/Сайн яваарай" &&
+
+   test_completion "git test-path-comp á" "árvíztűrő" &&
+   test_completion "git test-path-comp árvíztűrő/С" \
+   "árvíztűrő/Сайн яваарай"
+'
+
+if test_have_prereq !MINGW &&
+   mkdir 'New\Dir' 2>/dev/null &&
+   touch 'New\Dir/New"File.c' 2>/dev/null
+then
+   test_set_prereq FUNNYNAMES_BS_DQ
+else
+   say "Your filesystem does not allow \\ and \" in filenames."
+   rm -rf 'New\Dir'
+fi
+test_expect_failure FUNNYNAMES_BS_DQ \
+'complete files - C-style escapes in ls-files output' '
+   test_when_finished "rm -r \"NewDir\"" &&
+
+   test_completion "git test-path-comp N" "New\\Dir" &&
+   test_completion "git test-path-comp NewD" "New\\Dir" &&
+   test_completion "git test-path-comp NewDir/N" \
+   "New\\Dir/New\"File.c" &&
+   test_completion "git test-path-comp NewDir/New\\\"F" \
+   "New\\Dir/New\"File.c"
+'
+
+if test_have_prereq !MINGW &&
+   mkdir $'New\034Special\035Dir' 2>/dev/null &&
+   touch $'New\034Special\035Dir/New\036Special\037File' 2>/dev/null
+then
+   test_set_prereq FUNNYNAMES_SEPARATORS
+else
+   say 'Your filesystem does not allow special separator characters (FS, 
GS, RS, US) in filenames.'
+   rm -rf $'New\034Special\035Dir'
+fi
+test_expect_failure FUNNYNAMES_SEPARATORS \
+'complete files - \nnn-escaped control characters in ls-files output' '
+   test_when_finished "rm -r '$'New\034Special\035Dir''" &&
+
+   # Note: these will be literal separator characters on the cmdline.
+   test_completion "git test-path-comp N" "'$'New\034Special\035Dir''" &&
+   test_completion "git test-path-comp '$'New\034S''" \
+   "'$'New\034Special\035Dir''" &&
+   test_completion "git test-path-comp '$'New\034Special\035Dir/''" \
+   "'$'New\034Special\035Dir/New\036Special\037File''" &&
+   test_completion "git test-path-comp 
'$'New\034Special\035Dir/New\036S''" \
+   "'$'New\034Special\035Dir/New\036Special\037File''"
+'
+
+
 test_expect_success "completion uses  completion for alias: !sh -c 'git 
 ...'" '
test_config alias.co "!sh -c '"'"'git checkout ...'"'"'" &&
test_completion "git co m" <<-\EOF
-- 
2.17.0.366.gbe216a3084