Skip to contentSkip to conversation

Fix git-completion.bash for use in zsh

PATCH In review Alex Merry 3 participants 4 messages Jun 15, 2016

lore
Share & tools
lore

Alex Merry

author
#0 lore raw

PATCH v2 1/1 Fix git-completion.bash for use in zsh

zsh treats
local some_var=()
as a function declaration, rather than an array declaration (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 produce the message
local:2: command not found: svn_url_pattern
when GIT_PS1_SHOWUPSTREAM="auto", due to the line
local svn_remote=() svn_url_pattern count n

Simply doing
local some_var
some_var=()
fixes the issue.

---

Here it is again, with a better commit message, and no whitespace issues (hopefully).

 contrib/completion/git-completion.bash |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
contrib/completion/git-completion.bash +2 -1
index 0acbdda..092a34f 100755
@@ -94,8 +94,9 @@ __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 ')"
Signature · 1 line
1.7.6.5
#1 lore raw
Quoted 11 lines · Alex Merry

zsh treats
local some_var=()
as a function declaration, rather than an array declaration (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 produce the message
local:2: command not found: svn_url_pattern
when GIT_PS1_SHOWUPSTREAM="auto", due to the line
local svn_remote=() svn_url_pattern count n

Thanks, will queue. Felipe, comments?

Quoted 29 lines

Simply doing
local some_var
some_var=()
fixes the issue.

---

Here it is again, with a better commit message, and no whitespace issues (hopefully).

 contrib/completion/git-completion.bash |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
contrib/completion/git-completion.bash +2 -1
index 0acbdda..092a34f 100755
@@ -94,8 +94,9 @@ __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 ')"
#2 lore raw
Quoted 7 lines · Junio C Hamano
Quoted 5 lines · Alex Merry

zsh treats
  local some_var=()
as a function declaration, rather than an array declaration (although its documentation does not suggest that this should be the case).

Quoted 8 lines
Quoted 6 lines

With zsh 4.3.15 on Fedora Core 15, this causes
  __git_ps1 " (%s)"
to produce the message
  local:2: command not found: svn_url_pattern
when GIT_PS1_SHOWUPSTREAM="auto", due to the line
  local svn_remote=() svn_url_pattern count n

Thanks, will queue.  Felipe, comments?

Looks good to me. Also, I tested this, and it worked.

Signature · 1 line
Felipe Contreras
#3 lore raw
In reply to Alex Merry
Quoted 11 lines · Alex Merry

 __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 ')"
--

Actually, a more proper way to do this is 'local -a svn_remote'.

Cheers.

Signature · 1 line
Felipe Contreras