zsh-workers
 help / color / mirror / code / Atom feed
* [PATCH] _git: don't expand {alias} if _git-{alias} exists
@ 2012-10-18  7:28 Benjamin R. Haskell
  0 siblings, 0 replies; only message in thread
From: Benjamin R. Haskell @ 2012-10-18  7:28 UTC (permalink / raw)
  To: Zsh Workers; +Cc: zsh

From: "Benjamin R. Haskell" <zsh@benizi.com>

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


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2012-10-18  7:34 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-10-18  7:28 [PATCH] _git: don't expand {alias} if _git-{alias} exists Benjamin R. Haskell

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

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