@matheusbsbs / matheus-bagliano / commits / a44a0a9fc4
Fork 0

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 94408dc7, 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) <mail@3v1n0.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Marco Trevisan (Treviño) committed May 26, 2020 at 19:13 UTC a44a0a9fc4353ff4ccd4b2308db2844d7f4185f9
1 file changed +1 -1
contrib/completion/git-completion.bash
+1 -1
@@ -373,7 +373,7 @@ __gitcomp ()
373 # Clear the variables caching builtins' options when (re-)sourcing
374 # the completion script.
375 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
377 else
378 unset $(compgen -v __gitcomp_builtin_)
379 fi