Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

bash-completion: don't add quoted space for ZSH (fix regression)

Commit a31e626 (completion: optimize refs completion) introduced a
regression for ZSH users: ref names were completed with a quoted trailing
space (i.e. "git checkout ma" completes to "git checkout master\ "). The
space is convenient for bash users since we use "-o nospace", but a
quoted space is worse than nothing. The absence of trailing space for ZSH
is a long-standing issue, that this patch is not fixing. We just fix the
regression by not appending a space when the shell is ZSH.

Original-patch-by: SZEDER Gábor <>
Reported-by: Stefan Haller <>
Signed-off-by: Matthieu Moy <>
Signed-off-by: Junio C Hamano <>
  • Loading branch information...
commit de3c2bdec6197af170979730c9e9b29b57dc29e2 1 parent 5bb07cb
@moy moy authored dscho committed
Showing with 7 additions and 0 deletions.
  1. +7 −0 contrib/completion/git-completion.bash
7 contrib/completion/git-completion.bash
@@ -509,6 +509,13 @@ __gitcomp ()
__gitcomp_nl ()
local IFS=$'\n'
+ # ZSH would quote the trailing space added with -S. bash users
+ # will appreciate the extra space to compensate the use of -o nospace.
+ if [ -n "${ZSH_VERSION-}" ] && [ "$suffix" = " " ]; then
+ suffix=""
+ fi
COMPREPLY=($(compgen -P "${2-}" -S "${4- }" -W "$1" -- "${3-$cur}"))
Please sign in to comment.
Something went wrong with that request. Please try again.