about summary refs log tree commit diff
diff options
context:
space:
mode:
authorClint Adams <clint@users.sourceforge.net>2007-09-29 06:06:14 +0000
committerClint Adams <clint@users.sourceforge.net>2007-09-29 06:06:14 +0000
commit03718b3180a7d4ef07280dce5cc5a095d300060c (patch)
treeb7bafc7c34ecba0bff0f54a50ecd6d428f0a5816
parentb0f8a1eefa9a723f09f56cca26249296e4f54682 (diff)
downloadzsh-03718b3180a7d4ef07280dce5cc5a095d300060c.tar.gz
zsh-03718b3180a7d4ef07280dce5cc5a095d300060c.tar.xz
zsh-03718b3180a7d4ef07280dce5cc5a095d300060c.zip
Pierre Habouzit: 23851: use ad-hoc functions to list git branches and tags.
-rw-r--r--ChangeLog5
-rw-r--r--Completion/Unix/Command/_git28
2 files changed, 17 insertions, 16 deletions
diff --git a/ChangeLog b/ChangeLog
index c17ff9d42..401997838 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2007-09-29  Clint Adams  <clint@zsh.org>
+
+	* Pierre Habouzit: 23851: Completion/Unix/Command/_git: 
+	use ad-hoc functions to list git branches and tags.
+
 2007-09-28  Clint Adams  <clint@zsh.org>
 
 	* 23850: Completion/Unix/Command/_md5sum: complete for GNU md5sum
diff --git a/Completion/Unix/Command/_git b/Completion/Unix/Command/_git
index 976986113..73d986a3b 100644
--- a/Completion/Unix/Command/_git
+++ b/Completion/Unix/Command/_git
@@ -2846,30 +2846,26 @@ __git_signoff_file () {
 __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