From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 5428 invoked by alias); 18 Oct 2012 07:34:46 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: X-Seq: 30737 Received: (qmail 9303 invoked from network); 18 Oct 2012 07:34:34 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham version=3.3.2 Received-SPF: pass (ns1.primenet.com.au: SPF record at benizi.com designates 64.130.10.15 as permitted sender) From: "Benjamin R. Haskell" To: Zsh Workers Cc: Subject: [PATCH] _git: don't expand {alias} if _git-{alias} exists Date: Thu, 18 Oct 2012 03:28:55 -0400 Message-Id: <1350545335-10537-1-git-send-email-zsh@benizi.com> X-Mailer: git-send-email 1.7.8.4 From: "Benjamin R. Haskell" This allows easy creation of completion functions for aliases that are shell wrappers around other git functions. E.g. I have an alias for `git reset --hard` called `git hard`, which checks that I'm not resetting staged changes: $ git config alias.hard ! : reset hard unless staged ; if git diff --cached | grep -q . ; then echo You have staged changes ; return 1 ; fi ; git reset --hard Adding the following function lets me use the same completion: _git-hard () { _git-reset "$@" } --- Completion/Unix/Command/_git | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/Completion/Unix/Command/_git b/Completion/Unix/Command/_git index 88c765f..b8f3051 100644 --- a/Completion/Unix/Command/_git +++ b/Completion/Unix/Command/_git @@ -6073,7 +6073,7 @@ _git() { aliases=(${(f)${${${(f)"$(_call_program aliases git config --get-regexp '\^alias\.')"}#alias.}/ /$'\n'}/(#e)/$'\n'}) (( $#aliases % 2 == 0 )) && git_aliases=($aliases) - if (( $+git_aliases[$words[2]] && !$+commands[git-$words[2]] )); then + if (( $+git_aliases[$words[2]] && !$+commands[git-$words[2]] && !$+functions[_git-$words[2]] )); then local -a tmpwords expalias expalias=(${(z)git_aliases[$words[2]]}) tmpwords=(${words[1]} ${expalias}) -- 1.7.8.4