git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Marco Trevisan via GitGitGadget" <gitgitgadget@gmail.com>
To: git@vger.kernel.org
Cc: "Marco Trevisan" <mail@3v1n0.net>,
	"Marco Trevisan (Treviño)" <mail@3v1n0.net>
Subject: [PATCH] completion: use native ZSH array pattern matching
Date: Tue, 26 May 2020 19:13:17 +0000	[thread overview]
Message-ID: <pull.645.git.1590520398132.gitgitgadget@gmail.com> (raw)

From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= <mail@3v1n0.net>

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>
---
    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.

Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-645%2F3v1n0%2Fzsh-native-operation-v1
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-645/3v1n0/zsh-native-operation-v1
Pull-Request: https://github.com/gitgitgadget/git/pull/645

 contrib/completion/git-completion.bash | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
index 70ad04e1b2a..ad6934a3864 100644
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -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

base-commit: d2ecc46c0981fb829fdfb204604ed0a2798cbe07
-- 
gitgitgadget

             reply	other threads:[~2020-05-26 19:13 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-26 19:13 Marco Trevisan via GitGitGadget [this message]
2020-05-26 23:58 ` [PATCH] completion: use native ZSH array pattern matching brian m. carlson
2020-05-27  6:13   ` Carlo Marcelo Arenas Belón
2020-05-28  2:17     ` brian m. carlson
2020-05-28 15:54       ` Junio C Hamano
2020-05-28 22:57         ` brian m. carlson
2020-05-28 23:01           ` Junio C Hamano
2020-05-28 16:14 ` Junio C Hamano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=pull.645.git.1590520398132.gitgitgadget@gmail.com \
    --to=gitgitgadget@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=mail@3v1n0.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).