]> git.ipfire.org Git - thirdparty/git.git/commitdiff
completion: use native ZSH array pattern matching
authorMarco Trevisan (Treviño) <mail@3v1n0.net>
Tue, 26 May 2020 19:13:17 +0000 (19:13 +0000)
committerJunio C Hamano <gitster@pobox.com>
Thu, 28 May 2020 16:15:18 +0000 (09:15 -0700)
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>
contrib/completion/git-completion.bash

index 70ad04e1b2a8c65896c95c8e6bd34e963c74c687..ad6934a3864fdde73508e37064318520e0e22b00 100644 (file)
@@ -373,7 +373,7 @@ __gitcomp ()
 # Clear the variables caching builtins' options when (re-)sourcing
 # the completion script.
 if [[ -n ${ZSH_VERSION-} ]]; then
-       unset $(set |sed -ne 's/^\(__gitcomp_builtin_[a-zA-Z0-9_][a-zA-Z0-9_]*\)=.*/\1/p') 2>/dev/null
+       unset ${(M)${(k)parameters[@]}:#__gitcomp_builtin_*} 2>/dev/null
 else
        unset $(compgen -v __gitcomp_builtin_)
 fi