Skip to content

Commit f15026b

Browse files
felipecgitster
authored andcommitted
git-completion: workaround zsh COMPREPLY bug
zsh adds a backslash (foo\ ) for each item in the COMPREPLY array if IFS doesn't contain spaces. This issue has been reported[1], but there is no solution yet. This wasn't a problem due to another bug[2], which was fixed in zsh version 4.3.12. After this change, 'git checkout ma<tab>' would resolve to 'git checkout master\ '. Aditionally, the introduction of __gitcomp_nl in commit a31e626 (completion: optimize refs completion) in git also made the problem apparent, as Matthieu Moy reported. The simplest and most generic solution is to hide all the changes we do to IFS, so that "foo \nbar " is recognized by zsh as "foo bar". This works on versions of git before and after the introduction of __gitcomp_nl (a31e626), and versions of zsh before and after 4.3.12. Once zsh is fixed, we should conditionally disable this workaround to have the same benefits as bash users. [1] http://www.zsh.org/mla/workers/2012/msg00053.html [2] http://zsh.git.sourceforge.net/git/gitweb.cgi?p=zsh/zsh;a=commitdiff;h=2e25dfb8fd38dbef0a306282ffab1d343ce3ad8d Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent 7331374 commit f15026b

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

contrib/completion/git-completion.bash

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2631,6 +2631,10 @@ _git ()
26312631
# workaround zsh's bug that leaves 'words' as a special
26322632
# variable in versions < 4.3.12
26332633
typeset -h words
2634+
2635+
# workaround zsh's bug that quotes spaces in the COMPREPLY
2636+
# array if IFS doesn't contain spaces.
2637+
typeset -h IFS
26342638
fi
26352639

26362640
local cur words cword prev
@@ -2687,6 +2691,10 @@ _gitk ()
26872691
# workaround zsh's bug that leaves 'words' as a special
26882692
# variable in versions < 4.3.12
26892693
typeset -h words
2694+
2695+
# workaround zsh's bug that quotes spaces in the COMPREPLY
2696+
# array if IFS doesn't contain spaces.
2697+
typeset -h IFS
26902698
fi
26912699

26922700
local cur words cword prev

0 commit comments

Comments
 (0)