Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

[PATCH] improved git completion



Attached to this message you can find a series of patches to the
git completion file (installed as
/usr/share/zsh/4.3.2/functions/Completion/Unix/_git, no idea where
it lives in the source tree).  The five patches are base upon each
other and need to be applied in order.  I've split them up for
better readability.

0001*

  Removes trailing whitespace from the file.

0002*

  Fixes a syntax error in the completion code for git-clone.  Also
  replaces $* with $@ in some places and fixes a TODO in
  _git-rev-list.

0003*

  Adds completion of generic git options like "git --git-dir"

0004*

  Ports bash's completion code for heads, tags, branches etc. to
  zsh.  This code is *much* faster because is does not depend on
  the git-ls-remote command, does not require a network connection
  (for the same reason) and also properly handles the --git-dir
  argument as well as the GIT_DIR environment variable (for all
  git commands).

  Finally it rewrites the completion code of git-branch completely
  so that it works in all modes (list/create/delete/move
  branches).

Ciao

Dominik ^_^  ^_^

-- 
Dominik Vogt
From 565a6553c2612a041c6a8b8e71fb1789938490e2 Mon Sep 17 00:00:00 2001
From: Dominik Vogt <dvogt@xxxxxxxxxxxxxxxxxx>
Date: Wed, 23 Jan 2008 08:53:41 +0100
Subject: [PATCH] removed trailing whitespace

---
 _git |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/_git b/_git
index 7b76d5a..0a6cebf 100644
--- a/_git
+++ b/_git
@@ -3,8 +3,8 @@
 # Commands not completed:
 # git-sh-setup
 # git-shell
-# git-parse-remote 
-# git-rev-parse 
+# git-parse-remote
+# git-rev-parse
 
 # TODO: most commands need a valid git repository to run, so add a check for it
 # so that we can make our handling a little bit cleaner (need to deal with
@@ -544,7 +544,7 @@ _git-verify-pack () {
     '-v[show objects contained in pack]' \
     '*:index file:_files -g "*.idx"' && ret=0
 }
- 
+
 __git-clone_or_fetch-pack () {
   _arguments \
     $exec_arg \
@@ -1220,7 +1220,7 @@ _remote_files () {
     while _tags; do
       while _next_label files expl ${suf:-remote directory}; do
 #        [[ -n $suf ]] && compadd "$@" "$expl[@]" -d remdispf \
-#	    ${(q)remdispf%[*=@|]} && ret=0 
+#	    ${(q)remdispf%[*=@|]} && ret=0
 	compadd ${suf:+-S/} "$@" "$expl[@]" -d remdispd \
 	    ${(q)remdispd%/} && ret=0
       done
-- 
1.5.3.5.GIT

From 247eef0799cba3938f59d746830ef108d277acb6 Mon Sep 17 00:00:00 2001
From: Dominik Vogt <dvogt@xxxxxxxxxxxxxxxxxx>
Date: Wed, 23 Jan 2008 08:54:03 +0100
Subject: [PATCH] Fixed syntax error in git-clone completion

Fixed a todo and cleanup.
---
 _git |   16 ++++++++--------
 1 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/_git b/_git
index 0a6cebf..6677bac 100644
--- a/_git
+++ b/_git
@@ -488,7 +488,6 @@ _git-name-rev () {
     '(--stdin --all)*:commit-ish:__git_revisions' && ret=0
 }
 
-# TODO: --no-merges undocumented
 _git-rev-list () {
   if (( $words[(I)--] && $words[(I)--] != CURRENT )); then
     _arguments \
@@ -507,6 +506,7 @@ _git-rev-list () {
       '--max-count[maximum number of commits to output]: :_guard "[[\:digit\:]]#" timestamp' \
       '(--topo-order)--merge-order[decompose into minimal and maximal epochs]' \
       '--min-age[minimum age of commits to output]: :_guard "[[\:digit\:]]#" timestamp' \
+      '--no-merges[do not print commits with more than one parent]'
       '--parents[show parent commits]' \
       '(--header)'$pretty_arg \
       '(--dense)--sparse[when paths are given, output only commits that changes any of them]' \
@@ -726,7 +726,7 @@ _git-clone () {
 
   _arguments \
     '(-l --local)'{-l,--local}'[perform a local cloning of a repository]' \
-    $shared
+    $shared \
     '(-q --quiet)'{-q,--quiet}'[operate quietly]' \
     '-n[do not checkout HEAD after clone is complete]' \
     '(-u --upload-pack)'{-u,--uploadpack}'[specify path to git-upload-pack on remote side]:remote path' \
@@ -1138,23 +1138,23 @@ __git_guard () {
 }
 
 __git_objects () {
-  __git_guard $* "[[:xdigit:]]#" "object"
+  __git_guard $@ "[[:xdigit:]]#" "object"
 }
 
 __git_trees () {
-  __git_guard $* "[[:xdigit:]]#" "tree"
+  __git_guard $@ "[[:xdigit:]]#" "tree"
 }
 
 __git_tree_ishs () {
-  __git_guard $* "[[:xdigit:]]#" "tree-ish"
+  __git_guard $@ "[[:xdigit:]]#" "tree-ish"
 }
 
 __git_blobs () {
-  _git_guard $* "[[:xdigit:]]#" 'blob id'
+  _git_guard $@ "[[:xdigit:]]#" 'blob id'
 }
 
 __git_stages () {
-  __git_guard $* "[[:digit:]]#" 'stage'
+  __git_guard $@ "[[:digit:]]#" 'stage'
 }
 
 __git_files () {
@@ -1189,7 +1189,7 @@ __git_commits () {
 
 # TODO: deal with prefixes and suffixes listed in git-rev-parse
 __git_revisions () {
-  __git_commits $*
+  __git_commits
 }
 
 __git_commits2 () {
-- 
1.5.3.5.GIT

From 12950b7b976a85e6d60a2df4213b98a50e5696c6 Mon Sep 17 00:00:00 2001
From: Dominik Vogt <dvogt@xxxxxxxxxxxxxxxxxx>
Date: Wed, 23 Jan 2008 12:44:54 +0100
Subject: [PATCH] Add completion of git options.

---
 _git |  214 ++++++++++++++++++++++++++++++++++--------------------------------
 1 files changed, 111 insertions(+), 103 deletions(-)

diff --git a/_git b/_git
index 6677bac..6f6e82d 100644
--- a/_git
+++ b/_git
@@ -76,116 +76,124 @@ tags_fetch_arg=('(-t --tags)'{-t,--tags}'[fetch remote tags]')
 
 # TODO: either skip uninteresting commands or skip the description - the list
 # is just too long
-_git_commands () {
-  local -a commands
-
-  commands=(
-    'add:add paths to the index'
-    'am:apply patches from a mailbox (cooler than applymbox)'
-    'apply:apply patch on a git index file and a work tree'
-    'applymbox:apply patches from a mailbox'
-    'applypatch:apply one patch extracted from an e-mail'
-    'archimport:import an Arch repository into git'
-    'bisect:find the change that introduced a bug'
-    'branch:create and show branches'
-    'cat-file:provide content or type information for repository objects'
-    'check-ref-format:makes sure that a reference-name is well formed'
-    'checkout:checkout and switch to a branch'
-    'checkout-index:copy files from the index to the working directory'
-    'cherry:find commits not merged upstream'
-    'cherry-pick:cherry-pick the effect of an existing commit'
-    'clone:clones a repository into a new directory'
-    'clone-pack:clones a repository into the current repository (transport)'
-    'commit:record changes to the repository'
-    'commit-tree:creates a new commit object'
-    'convert-objects:converts old-style git repository'
-    'count-objects:count unpacked objects and display their disk consumption'
-    'cvsimport:import a CVS "repository" into a git repository'
-    'daemon:starts a really simple server for git repositories'
-    'diff:show changes between commits, commit and working tree, etc.'
-    'diff-files:compares files in the working tree and the index'
-    'diff-index:compares content and mode of blobs between index and repository'
-    'diff-stages:compares two "merge states" in the index file'
-    'diff-tree:compares the content and mode of blobs found via two tree objects'
-    'fetch:download objects and a head from another repository'
-    'fetch-pack:receive missing objects from another repository'
-    'format-patch:prepare patches for e-mail submission'
-    'fsck-objects:verifies the connectivity and validity of the objects in the database'
-    'get-tar-commit-id:extract commit ID from an archive created using tar-tree'
-    'grep:print lines matching a pattern'
-    'hash-object:computes the object ID from a file'
-    'http-fetch:downloads a remote git repository via HTTP'
-    'index-pack:build pack index file for an existing packed archive'
-    'init-db:creates an empty git object database'
-    'local-fetch:duplicates another git repository on a local system'
-    'log:shows commit logs'
-    'lost-found:recovers lost references that luckily have not yet been pruned'
-    'ls-files:information about files in the index/working directory'
-    'ls-remote:shows references in a remote or local repository'
-    'ls-tree:displays a tree object in human-readable form'
-    'mailinfo:extracts patch from a single e-mail message'
-    'mailsplit:splits an mbox file into a list of files'
-    'merge:grand unified merge driver'
-    'merge-base:finds a good common ancestor as possible for a merge'
-    'merge-index:runs a merge for files needing merging'
-    'merge-one-file:standard helper-program to use with merge-index'
-    'mktag:creates a tag object'
-    'mv:moves or renames a file, directory, or symlink'
-    'name-rev:find symbolic names for given revisions'
-    'octopus:merges more than two commits'
-    'pack-objects:creates a packed archive of objects'
-    'parse-remote:routines to help parsing $GIT_DIR/remotes/'
-    'patch-id:computes unique ID for a apatch'
-    'peek-remote:lists references on a remote repository using the upload-pack protocol'
-    'prune:prunes all unreachable objects from the object database'
-    'prune-packed:removes extra objects that are already in pack files'
-    'pull:fetch from and merge with a remote repository'
-    'push:update remote refs along with associated objects'
-    'read-tree:reads tree information into the directory index'
-    'rebase:rebases local commits to new upstream head'
-    'receive-pack:command invoked by send-pack to receive what is pushed to it'
-    'relink:hardlinks acommon objects in local repositories'
-    'repack:packs unpacked objects in a repository'
-    'request-pull:generates a summary of pending changes'
-    'reset:resets current HEAD to the specified state'
-    'resolve:merges two commits'
-    'rev-list:lists commit object in reverse chronological order'
-    'rev-parse:picks out and massages parameters for other git commands'
-    'revert:reverts an existing commit'
-    'send-email:sends patch-e-mails out of "format-patch --mbox" output'
-    'send-pack:pushes to a remote repository, intelligently'
-    'shortlog:summarizes git log output'
-    'show-branch:shows branches and their commits'
-    'show-index:displays contents of a pack idx file'
-    'ssh-fetch:pulls from a remote repository over an SSH connection'
-    'ssh-upload:helper "server-side" program used by ssh-fetch'
-    "status:shows the working-tree's status"
-    'stripspace:filters out empty lines'
-    'svnimport:imports a SVN repository into git'
-    'symbolic-ref:reads and modifies symbolic references'
-    'tag:creates a tag object signed with GPG'
-    'tar-tree:creates a tar archive of the files in the named tree'
-    "unpack-file:creates a temporary file with a blob's contents"
-    'unpack-objects:unpacks objects out of a packed archive'
-    'update-index:modifies the index in some given way'
-    'update-ref:updates the object name stored in a reference safely'
-    'update-server-info:updates auxiliary information on a dumb server'
-    'upload-pack:command invoked by clone-pack and fetch-pack'
-    'var:displays a git logical variable'
-    'verify-pack:validates packed git archive files'
-    'verify-tag:checks the GPG signature of a tag'
-    'whatchanged:shows commit-logs and differences they introduce'
-    'write-tree:creates a tree from the current index')
-
-  _describe -t commands 'git command' commands && ret=0
+_git_command_options () {
+  _values 'gitoptions' \
+    '--git-dir[path to repository]:git dir:_directories' \
+    '--exec-path[path to git core files]:git core dir:_directories' \
+    '--work-tree[path to the working tree]:work dir:_directories' \
+    '--bare[treat repository as bare]' \
+    '--help[print help]' \
+    '(-p --paginate)'{-p,--paginate}'[pipe all output into less]' \
+    '--no-pager[do not pipe output into a pager]' \
+    '--version[print git version]' \
+    'add[add paths to the index]' \
+    'am[apply patches from a mailbox (cooler than applymbox)]' \
+    'apply[apply patch on a git index file and a work tree]' \
+    'applymbox[apply patches from a mailbox]' \
+    'applypatch[apply one patch extracted from an e-mail]' \
+    'archimport[import an Arch repository into git]' \
+    'bisect[find the change that introduced a bug]' \
+    'branch[create and show branches]' \
+    'cat-file[provide content or type information for repository objects]' \
+    'check-ref-format[makes sure that a reference-name is well formed]' \
+    'checkout[checkout and switch to a branch]' \
+    'checkout-index[copy files from the index to the working directory]' \
+    'cherry[find commits not merged upstream]' \
+    'cherry-pick[cherry-pick the effect of an existing commit]' \
+    'clone[clones a repository into a new directory]' \
+    'clone-pack[clones a repository into the current repository (transport)]' \
+    'commit[record changes to the repository]' \
+    'commit-tree[creates a new commit object]' \
+    'convert-objects[converts old-style git repository]' \
+    'count-objects[count unpacked objects and display their disk consumption]' \
+    'cvsimport[import a CVS "repository" into a git repository]' \
+    'daemon[starts a really simple server for git repositories]' \
+    'diff[show changes between commits, commit and working tree, etc.]' \
+    'diff-files[compares files in the working tree and the index]' \
+    'diff-index[compares content and mode of blobs between index and repository]' \
+    'diff-stages[compares two "merge states" in the index file]' \
+    'diff-tree[compares the content and mode of blobs found via two tree objects]' \
+    'fetch[download objects and a head from another repository]' \
+    'fetch-pack[receive missing objects from another repository]' \
+    'format-patch[prepare patches for e-mail submission]' \
+    'fsck-objects[verifies the connectivity and validity of the objects in the database]' \
+    'get-tar-commit-id[extract commit ID from an archive created using tar-tree]' \
+    'grep[print lines matching a pattern]' \
+    'hash-object[computes the object ID from a file]' \
+    'http-fetch[downloads a remote git repository via HTTP]' \
+    'index-pack[build pack index file for an existing packed archive]' \
+    'init-db[creates an empty git object database]' \
+    'local-fetch[duplicates another git repository on a local system]' \
+    'log[shows commit logs]' \
+    'lost-found[recovers lost references that luckily have not yet been pruned]' \
+    'ls-files[information about files in the index/working directory]' \
+    'ls-remote[shows references in a remote or local repository]' \
+    'ls-tree[displays a tree object in human-readable form]' \
+    'mailinfo[extracts patch from a single e-mail message]' \
+    'mailsplit[splits an mbox file into a list of files]' \
+    'merge[grand unified merge driver]' \
+    'merge-base[finds a good common ancestor as possible for a merge]' \
+    'merge-index[runs a merge for files needing merging]' \
+    'merge-one-file[standard helper-program to use with merge-index]' \
+    'mktag[creates a tag object]' \
+    'mv[moves or renames a file, directory, or symlink]' \
+    'name-rev[find symbolic names for given revisions]' \
+    'octopus[merges more than two commits]' \
+    'pack-objects[creates a packed archive of objects]' \
+    'parse-remote[routines to help parsing $GIT_DIR/remotes/]' \
+    'patch-id[computes unique ID for a apatch]' \
+    'peek-remote[lists references on a remote repository using the upload-pack protocol]' \
+    'prune[prunes all unreachable objects from the object database]' \
+    'prune-packed[removes extra objects that are already in pack files]' \
+    'pull[fetch from and merge with a remote repository]' \
+    'push[update remote refs along with associated objects]' \
+    'read-tree[reads tree information into the directory index]' \
+    'rebase[rebases local commits to new upstream head]' \
+    'receive-pack[command invoked by send-pack to receive what is pushed to it]' \
+    'relink[hardlinks acommon objects in local repositories]' \
+    'repack[packs unpacked objects in a repository]' \
+    'request-pull[generates a summary of pending changes]' \
+    'reset[resets current HEAD to the specified state]' \
+    'resolve[merges two commits]' \
+    'rev-list[lists commit object in reverse chronological order]' \
+    'rev-parse[picks out and massages parameters for other git commands]' \
+    'revert[reverts an existing commit]' \
+    'send-email[sends patch-e-mails out of "format-patch --mbox" output]' \
+    'send-pack[pushes to a remote repository, intelligently]' \
+    'shortlog[summarizes git log output]' \
+    'show-branch[shows branches and their commits]' \
+    'show-index[displays contents of a pack idx file]' \
+    'ssh-fetch[pulls from a remote repository over an SSH connection]' \
+    'ssh-upload[helper "server-side" program used by ssh-fetch]' \
+    "status[shows the working-tree's status]" \
+    'stripspace[filters out empty lines]' \
+    'svnimport[imports a SVN repository into git]' \
+    'symbolic-ref[reads and modifies symbolic references]' \
+    'tag[creates a tag object signed with GPG]' \
+    'tar-tree[creates a tar archive of the files in the named tree]' \
+    "unpack-file[creates a temporary file with a blob's contents]" \
+    'unpack-objects[unpacks objects out of a packed archive]' \
+    'update-index[modifies the index in some given way]' \
+    'update-ref[updates the object name stored in a reference safely]' \
+    'update-server-info[updates auxiliary information on a dumb server]' \
+    'upload-pack[command invoked by clone-pack and fetch-pack]' \
+    'var[displays a git logical variable]' \
+    'verify-pack[validates packed git archive files]' \
+    'verify-tag[checks the GPG signature of a tag]' \
+    'whatchanged[shows commit-logs and differences they introduce]' \
+    'write-tree[creates a tree from the current index]' && ret=0
 }
 
 # TODO: this needs to be cleaned up and fixed
 local curcontext=$curcontext ret=1
+local first=1
 
 if [[ $words[1] == git ]]; then
+  while [[ $#words -ge 3 && $words[2] == -* ]]; do
+    compset -n 2
+  done
   if (( CURRENT == 2 )); then
-    _git_commands
+    _git_command_options
   else
     shift words
     (( CURRENT-- ))
-- 
1.5.3.5.GIT

From e5f00906cf7c8644500ad1eff39ad7f70be9d103 Mon Sep 17 00:00:00 2001
From: Dominik Vogt <dvogt@xxxxxxxxxxxxxxxxxx>
Date: Wed, 23 Jan 2008 13:02:49 +0100
Subject: [PATCH] ported completion of remote heads and tags from bash

also handle --git-dir= option and GIT_DIR environment variable

better completion of git-branch
---
 _git |  170 +++++++++++++++++++++++++++++++++++++++++++----------------------
 1 files changed, 112 insertions(+), 58 deletions(-)

diff --git a/_git b/_git
index 6f6e82d..6bc8a37 100644
--- a/_git
+++ b/_git
@@ -184,13 +184,30 @@ _git_command_options () {
     'write-tree[creates a tree from the current index]' && ret=0
 }
 
-# TODO: this needs to be cleaned up and fixed
 local curcontext=$curcontext ret=1
-local first=1
+local gitdir="$GITDIR"
+local curgitdir=""
+local gitdir_arg=""
 
 if [[ $words[1] == git ]]; then
   while [[ $#words -ge 3 && $words[2] == -* ]]; do
-    compset -n 2
+    if [[ $words[2] == --git-dir=* ]]; then
+      gitdir=${words[2]#--git-dir=}
+      compset -n 2
+    elif [[ $words[2] == --git-dir && $#words -ge 4 ]]; then
+      gitdir=$words[3]
+      compset -n 2
+      compset -n 2
+    elif [[ "$words[2]" == --exec-path=* || "$words[2]" == --work-tree=* ]];
+    then
+      compset -n 2
+    elif [[ $words[2] == --exec-path || $words[2] == --work-tree && \
+      $#words -ge 4 ]]; then
+      compset -n 2
+      compset -n 2
+    else
+      compset -n 2
+    fi
   done
   if (( CURRENT == 2 )); then
     _git_command_options
@@ -204,6 +221,27 @@ else
   _call_function ret _$words[1]
 fi
 
+__gitdir ()
+{
+  if [[ "$1" != "$gitdir_arg" || -z "$curgitdir" ]]; then
+    if [[ -z $gitdir ]]; then
+      if [[ -z "$1" ]]; then
+        if [[ -n "$gitdir" ]]; then
+          curgitdir="$gitdir"
+        elif [[ -d .git ]]; then
+          curgitdir=".git"
+        else
+          curgitdir=$(git-rev-parse --git-dir 2>/dev/null)
+        fi
+      elif [[ -d "$1/.git" ]]; then
+        curgitdir="$1/.git"
+      else
+        curgitdir="$1"
+      fi
+    fi
+  fi
+}
+
 _git-apply () {
   _arguments \
     $nul_arg \
@@ -703,11 +741,46 @@ _git-bisect () {
 }
 
 _git-branch () {
-  _arguments \
-    '(-D)-d[delete a branch, which must be fully merged]' \
-    '(-d)-D[delete a branch]' \
-    ':branch-name' \
-    ':base branch:__git_revisions' && ret=0
+  local mode=
+
+  # find out syntax mode
+  { (( $words[(I)-(d|D)] )) && mode=del } ||
+  { (( $words[(I)-(m|M)] )) && mode=move } ||
+  { (( $words[(I)-(a|r|f)] )) && mode=list_create } ||
+  { (( CURRENT > 2 && CURRENT > $words[(i)^-*] )) && mode=list_create }
+  # remove options
+  while [[ CURRENT -gt 2 && -n $words[2] && $words[2] == -* ]]; do
+    compset -n 2
+  done
+  case "$mode" in
+    list_create)
+      ;;
+    del)
+      if (( $words[(I)-r] )); then
+        _arguments '*:new branch:__git_remote_branch' && ret=0
+      else
+        _arguments \
+          '(-r)-r[delete remote tracking branches]' \
+          '*:old branch:__git_local_branch' && ret=0
+      fi
+      ;;
+    move)
+      _arguments \
+        '1:old branch:__git_local_branch' \
+        '2:new branch:' && ret=0
+      ;;
+    *)
+      _arguments \
+        - '(options)' \
+          '-f[create branch forcefully]' \
+          '-a[list all branches]' \
+          '-r[list remote branches]' \
+          '-d[delete a branch, which must be fully merged]' \
+          '-D[delete a branch forcefully]' \
+          '-m[move branch]:m:->move' \
+          '-M[move branch forcefully]:M:->move' && ret=0
+      ;;
+  esac
 }
 
 _git-checkout () {
@@ -809,7 +882,7 @@ _git-ls-remote () {
     '(-h --heads)'{-h,--heads}'[show only refs under refs/heads]' \
     '(-t --tags)'{-t,--tags}'[show only refs under refs/tags]' \
     ':repository:__git_any_repositories' \
-    '*: :__git_references' && ret=0
+    '*: :__git_all_references' && ret=0
 }
 
 _git-merge () {
@@ -1190,9 +1263,7 @@ __git_tree_files () {
 # TODO: deal with things that __git_heads and __git_tags has in common (i.e.,
 # if both exists, they need to be completed to heads/x and tags/x.
 __git_commits () {
-  _alternative \
-    'heads::__git_heads' \
-    'tags::__git_tags'
+  __git_all_references
 }
 
 # TODO: deal with prefixes and suffixes listed in git-rev-parse
@@ -1283,70 +1354,53 @@ __git_signoff_file () {
 __git_tag_ids () {
 }
 
-__git_heads_or_tags () {
+__git_references () {
+  local cmd i is_hash=y
   local expl
-  typeset -a refs opts
-  typeset -A ours
-
-  zparseopts -K -D -a opts S: M: J: V: 1 2 n F: X: P:=ours T:=ours
-
-  (( $+ours[-P] )) || ours[-P]=./.
-
-  refs=(${${"${(@f)$(git ls-remote --$ours[-T] $ours[-P] 2>/dev/null)}"#*$'\t'}#refs/$ours[-T]/})
-  if (( $? == 0 )); then
-    _wanted $ours[-T] expl $ours[-T] compadd $opts - $refs
+  local path1="$1" path2="$2"
+
+  shift 2
+  __gitdir
+  if [[ -d "$curgitdir" ]]; then
+    for i in $(git --git-dir="$curgitdir" \
+      for-each-ref --format='%(refname)' \
+      refs"$path1$path2" ); do
+      _wanted "$path2" expl "$path2" compadd $@ - "${i#refs$path1$path2/}"
+    done
   else
     _message 'not a git repository'
   fi
 }
 
 __git_heads () {
-  __git_heads_or_tags $* -T heads && ret=0
+  __git_references / heads $@ && ret=0
 }
 
 __git_tags () {
-  __git_heads_or_tags $* -T tags && ret=0
+  __git_references / tags $@ && ret=0
 }
 
-# TODO: depending on what options are on the command-line already, complete
-# only tags or heads
-# TODO: perhaps caching is unnecessary.  usually wonâ??t contain that much data
-# TODO: perhaps provide alternative here for both heads and tags (and use
-# __git_heads and __git_tags)
-# TODO: instead of "./.", we should be looking in the repository specified as
-# an argument to the command (but default to "./." I suppose (why not "."?))
-__git_references () {
-#  _alternative \
-#    'heads::__git_heads' \
-#    'tags::__git_tags' && ret=0
-  local expl
-
-  # TODO: deal with GIT_DIR
-  if [[ $_git_refs_cache_pwd != $PWD ]]; then
-    _git_refs_cache=(${${"${(@f)$(git ls-remote ./. 2>/dev/null)}"#*$'\t'}#refs/(heads|tags)/})
-    _git_refs_cache_pwd=$PWD
-  fi
+__git_remotes () {
+  __git_references /remotes "" $@ && ret=0
+}
 
-  if (( $? == 0 )); then
-    _wanted references expl 'references' compadd - $_git_refs_cache
-  else
-    _message 'not a git repository'
-  fi
+__git_all_references () {
+  __git_heads && ret=0
+  __git_tags && ret=0
+  __git_remotes && ret=0
 }
 
 __git_local_references () {
-  local expl
+  __git_heads && ret=0
+  __git_tags && ret=0
+}
 
-  if [[ $_git_local_refs_cache_pwd != $PWD ]]; then
-    _git_local_refs_cache=(${${"${(@f)$(git ls-remote ./. 2>/dev/null)}"#*$'\t'}#refs/})
-    _git_local_refs_cache_pwd=$PWD
-  fi
+__git_local_branch () {
+  __git_heads && ret=0
+}
 
-  if (( $? == 0 )); then
-    _wanted references expl 'references' compadd - $_git_local_refs_cache
-  else
-    _message 'not a git repository'
-  fi
+__git_remote_branch () {
+  __git_remotes && ret=0
 }
 
 # ---
-- 
1.5.3.5.GIT



Messages sorted by: Reverse Date, Date, Thread, Author