contrib/completion: "local var=()" is misinterpreted as func-decl by zsh

Certain versions of zsh seems to treat local var=() as a function declaration, rather than an assignment of an empty array, although its documentation does not suggest that this should be the case. With zsh 4.3.15 on Fedora Core 15, this causes __git_ps1 " (%s)" to trigger an error message: local:2: command not found: svn_url_pattern when GIT_PS1_SHOWUPSTREAM="auto". Signed-off-by: Alex Merry <dev@randomguy3.me.uk> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Alex Merry committed Sep 1, 2011 at 14:47 UTC 471dcfdbb23ad423168d928335bc36217f9e311d
1 file changed +2 -1
contrib/completion/git-completion.bash
+2 -1
@@ -106,9 +106,10 @@ __gitdir ()
106 __git_ps1_show_upstream ()
107 {
108 local key value
109 - local svn_remote=() svn_url_pattern count n
109 + local svn_remote svn_url_pattern count n
110 local upstream=git legacy="" verbose=""
111
112 + svn_remote=()
113 # get some config options from git-config
114 local output="$(git config -z --get-regexp '^(svn-remote\..*\.url|bash\.showupstream)$' 2>/dev/null | tr '\0\n' '\n ')"
115 while read -r key value; do