zsh: complete unquoted paths with spaces correctly

The following is the description of -Q flag of zsh compadd [1]: This flag instructs the completion code not to quote any metacharacters in the words when inserting them into the command line. Let's say there is a file named 'foo bar.txt' in repository, but it's not yet added to the repository. Then the following command triggers a completion: git add fo<Tab> git add 'fo<Tab> git add "fo<Tab> The completion results in bash: git add foo\ bar.txt git add 'foo bar.txt' git add "foo bar.txt" While them in zsh: git add foo bar.txt git add 'foo bar.txt' git add "foo bar.txt" The first one, where the pathname is not enclosed in quotes, should escape the space with a backslash, just like bash completion does. Otherwise, this leads git to think there are two files; foo, and bar.txt. The main cause of this behavior is __gitcomp_file_direct(). The both implementions of bash and zsh are called with an argument 'foo bar.txt', but only bash adds a backslash before a space on command line. [1]: http://zsh.sourceforge.net/Doc/Release/Completion-Widgets.html Signed-off-by: Chayoung You <yousbe@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Chayoung You committed Jan 1, 2019 at 23:05 UTC 7a478b36aa1f202aed207a230def66563227f30e
2 files changed +4 -4
contrib/completion/git-completion.bash
+2 -2
@@ -2993,7 +2993,7 @@ if [[ -n ${ZSH_VERSION-} ]] &&
2993
2994 local IFS=$'\n'
2995 compset -P '*[=:]'
2996 - compadd -Q -f -- ${=1} && _ret=0
2996 + compadd -f -- ${=1} && _ret=0
2997 }
2998
2999 __gitcomp_file ()
@@ -3002,7 +3002,7 @@ if [[ -n ${ZSH_VERSION-} ]] &&
3002
3003 local IFS=$'\n'
3004 compset -P '*[=:]'
3005 - compadd -Q -p "${2-}" -f -- ${=1} && _ret=0
3005 + compadd -p "${2-}" -f -- ${=1} && _ret=0
3006 }
3007
3008 _git ()
contrib/completion/git-completion.zsh
+2 -2
@@ -99,7 +99,7 @@ __gitcomp_file_direct ()
99
100 local IFS=$'\n'
101 compset -P '*[=:]'
102 - compadd -Q -f -- ${=1} && _ret=0
102 + compadd -f -- ${=1} && _ret=0
103 }
104
105 __gitcomp_file ()
@@ -108,7 +108,7 @@ __gitcomp_file ()
108
109 local IFS=$'\n'
110 compset -P '*[=:]'
111 - compadd -Q -p "${2-}" -f -- ${=1} && _ret=0
111 + compadd -p "${2-}" -f -- ${=1} && _ret=0
112 }
113
114 __git_zsh_bash_func ()