Skip to content

Commit a44a0a9

Browse files
3v1n0gitster
authored andcommitted
completion: use native ZSH array pattern matching
When clearing the builtin operations on re-sourcing in the ZSH case we can use the native ${parameters} associative array keys values to get the currently `__gitcomp_builtin_*` operations using pattern matching instead of using sed. As also stated in commit 94408dc, introducing this change the usage of sed has some overhead implications, while ZSH can do this check just using its native syntax. Signed-off-by: Marco Trevisan (Treviño) <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 2d5e9f3 commit a44a0a9

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

contrib/completion/git-completion.bash

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -373,7 +373,7 @@ __gitcomp ()
373373
# Clear the variables caching builtins' options when (re-)sourcing
374374
# the completion script.
375375
if [[ -n ${ZSH_VERSION-} ]]; then
376-
unset $(set |sed -ne 's/^\(__gitcomp_builtin_[a-zA-Z0-9_][a-zA-Z0-9_]*\)=.*/\1/p') 2>/dev/null
376+
unset ${(M)${(k)parameters[@]}:#__gitcomp_builtin_*} 2>/dev/null
377377
else
378378
unset $(compgen -v __gitcomp_builtin_)
379379
fi

0 commit comments

Comments
 (0)