Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: bug in _git: (was Re: _git:6147: math recursion limit exceeded )



Hi there,

Michal Maruska wrote:
> I have some  "third party" git commands with provided zsh completion.
>
> They are named _git-segment  _git-segment-name  etc.
>
> I see this relevant code in _git:
>
> line 6139:
> declare -gUa _git_third_party_commands
>
> I would have expected  -A associative array.
>
> then:
>
> local name=${${file:t}#_git-}
> if (( $+_git_third_party_commands[$name] )); then
> ....

No, the original code was not written with assoc. arrays in mind.

The problem however is that arithmetic expansion is in implicitly in
place with subscripts of ordinary arrays, which is not done with assoc.
arrays - which might have led you to the conclusion, that those kind of
arrays were supposed to be in use there.

In reality, the array is formed for direct consumption by _describe.


Michal Maruska wrote:
> It turned out, that
> _git_third_party_commands+=$name$desc
> should be
> _git_third_party_commands+=($name $desc)

No, not really.

Turns out the way the look-up is done was changed in one of Nikolai's
rewrites. The way it was done before avoids the arithmetic expression
and thus fixes the problem. Here's a patch:


diff --git a/Completion/Unix/Command/_git b/Completion/Unix/Command/_git
index 2b6a369..cf9b498 100644
--- a/Completion/Unix/Command/_git
+++ b/Completion/Unix/Command/_git
@@ -6142,7 +6142,7 @@ _git_third_party_commands=()
 local file
 for file in ${^fpath}/_git-*~(*~|*.zwc)(.N); do
   local name=${${file:t}#_git-}
-  if (( $+_git_third_party_commands[$name] )); then
+  if [[ -n ${(M)_git_third_party:#${name}*} ]]; then
     continue
   fi
 



Messages sorted by: Reverse Date, Date, Thread, Author