From: Clint Adams <clint@zsh.org>
To: zsh-workers@sunsite.dk
Cc: madcoder@debian.org
Subject: PATCH: _git, Use ad-hoc functions to list branches/tags
Date: Sat, 29 Sep 2007 02:02:31 -0400 [thread overview]
Message-ID: <20070929060231.GA790@scowler.net> (raw)
Patch from Pierre Habouzit to allow completion for origin/* branches.
Index: Completion/Unix/Command/_git
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Unix/Command/_git,v
retrieving revision 1.29
diff -u -r1.29 _git
--- Completion/Unix/Command/_git 27 Sep 2007 12:40:27 -0000 1.29
+++ Completion/Unix/Command/_git 29 Sep 2007 06:00:36 -0000
@@ -2846,30 +2846,26 @@
__git_tag_ids () {
}
-(( $+functions[__git_heads_or_tags] )) ||
-__git_heads_or_tags () {
+(( $+functions[__git_heads] )) ||
+__git_heads () {
local expl
- declare -a refs opts
- declare -A ours
-
- zparseopts -K -D -a opts S: M: J: V: 1 2 n F: X: P:=ours T:=ours
-
- (( $+ours[-P] )) || ours[-P]=./.
+ declare -a branch_names
- refs=(${${${${(f)"$(_call_program $ours[-T] git ls-remote --$ours[-T] $ours[-P] 2>/dev/null)"}#*$'\t'}:#*\^*}#refs/$ours[-T]/})
+ branch_names=(${${(f)"$(_call_program heads git branch -a 2>/dev/null)"}#[* ] })
__git_command_successful || return
- _wanted $ours[-T] expl $ours[-T] compadd $opts - $refs
-}
-
-(( $+functions[__git_heads] )) ||
-__git_heads () {
- __git_heads_or_tags $* -T heads && ret=0
+ _wanted heads expl branch-name compadd $* - $branch_names
}
(( $+functions[__git_tags] )) ||
__git_tags () {
- __git_heads_or_tags $* -T tags && ret=0
+ local expl
+ declare -a tag_names
+
+ tag_names=(${${(f)"$(_call_program tags git tag -l 2>/dev/null)"}#[* ] })
+ __git_command_successful || return
+
+ _wanted tags expl tag-name compadd $* - $tag_names
}
# TODO: depending on what options are on the command-line already, complete
reply other threads:[~2007-09-29 6:02 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20070929060231.GA790@scowler.net \
--to=clint@zsh.org \
--cc=madcoder@debian.org \
--cc=zsh-workers@sunsite.dk \
/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.
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).