contrib/completion: "local var=()" is misinterpreted as func-decl by zsh
authorAlex Merry <dev@randomguy3.me.uk>
Thu, 1 Sep 2011 13:47:31 +0000 (14:47 +0100)
committerJunio C Hamano <gitster@pobox.com>
Wed, 21 Mar 2012 17:02:39 +0000 (10:02 -0700)
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>
contrib/completion/git-completion.bash

index d7367e9faa87482f638ae4e16df38aa1bb853c40..99fea1db28fc084e59a05295fbf8c7665dac5a58 100755 (executable)
@@ -106,9 +106,10 @@ __gitdir ()
 __git_ps1_show_upstream ()
 {
        local key value
-       local svn_remote=() svn_url_pattern count n
+       local svn_remote svn_url_pattern count n
        local upstream=git legacy="" verbose=""
 
+       svn_remote=()
        # get some config options from git-config
        local output="$(git config -z --get-regexp '^(svn-remote\..*\.url|bash\.showupstream)$' 2>/dev/null | tr '\0\n' '\n ')"
        while read -r key value; do