completion: zsh: fix for command aliasing

A lot of people want to define aliases like gc='git commit', and zsh allows that (when not using 'complete_aliases'), but we need to handle services that call a function other than the main one. With this patch we can do: compdef _git gc=git_commit Additionally, add compatibility for Zsh Git functions which have the form git-commit (with dash, not underscore). Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Felipe Contreras committed Oct 27, 2020 at 20:06 UTC 81f717bb268e86eee5701b8199d8f030938a184c
1 file changed +5 -1
contrib/completion/git-completion.zsh
+5 -1
@@ -243,8 +243,12 @@ _git ()
243
244 if (( $+functions[__${service}_zsh_main] )); then
245 __${service}_zsh_main
246 - else
246 + elif (( $+functions[__${service}_main] )); then
247 emulate ksh -c __${service}_main
248 + elif (( $+functions[_${service}] )); then
249 + emulate ksh -c _${service}
250 + elif (( $+functions[_${service//-/_}] )); then
251 + emulate ksh -c _${service//-/_}
252 fi
253
254 let _ret && _default && _ret=0