From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 27550 invoked from network); 3 Jul 2007 07:04:46 -0000 X-Spam-Checker-Version: SpamAssassin 3.2.1 (2007-05-02) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.5 required=5.0 tests=AWL,BAYES_00 autolearn=ham version=3.2.1 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by ns1.primenet.com.au with SMTP; 3 Jul 2007 07:04:46 -0000 Received-SPF: none (ns1.primenet.com.au: domain at sunsite.dk does not designate permitted sender hosts) Received: (qmail 59757 invoked from network); 3 Jul 2007 07:04:40 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 3 Jul 2007 07:04:40 -0000 Received: (qmail 9955 invoked by alias); 3 Jul 2007 07:04:37 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 23644 Received: (qmail 9946 invoked from network); 3 Jul 2007 07:04:36 -0000 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by sunsite.dk with SMTP; 3 Jul 2007 07:04:36 -0000 Received: (qmail 59473 invoked from network); 3 Jul 2007 07:04:36 -0000 Received: from acolyte.scowler.net (216.254.112.45) by a.mx.sunsite.dk with SMTP; 3 Jul 2007 07:04:30 -0000 Received: by acolyte.scowler.net (Postfix, from userid 1000) id 40FAA5C3C6; Tue, 3 Jul 2007 03:04:23 -0400 (EDT) Date: Tue, 3 Jul 2007 03:04:24 -0400 From: Clint Adams To: zsh-workers@sunsite.dk Subject: PATCH: _git remote Message-ID: <20070703070424.GA3142@scowler.net> Mail-Followup-To: zsh-workers@sunsite.dk MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable User-Agent: Mutt/1.5.13 (2006-08-11) =66rom Nikolai's Index: Completion/Unix/Command/_git =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D RCS file: /cvsroot/zsh/zsh/Completion/Unix/Command/_git,v retrieving revision 1.13 diff -u -r1.13 _git --- Completion/Unix/Command/_git 2 Jul 2007 15:59:18 -0000 1.13 +++ Completion/Unix/Command/_git 3 Jul 2007 07:01:54 -0000 @@ -1,4 +1,4 @@ -#compdef git git-annotate git-apply git-checkout-index git-clean git-commi= t-tree git-describe git-hash-object git-index-pack git-init-db git-merge-in= dex git-merge-tree git-mktag git-mktree git-pack-objects git-prune-packed g= it-read-tree git-unpack-objects git-update-index git-write-tree git-cat-fil= e git-diff-index git-diff-files git-diff-stages git-diff-tree git-fsck-obje= cts git-ls-files git-ls-tree git-quiltimport git-merge-base git-name-rev gi= t-rev-list git-show-index git-tar-tree git-unpack-file git-var git-verify-p= ack git-clone-pack git-fetch-pack git-http-fetch git-local-fetch git-peek-r= emote git-receive-pack git-send-pack git-ssh-fetch git-ssh-upload git-updat= e-server-info git-upload-pack git-add git-am git-applymbox git-bisect git-b= ranch git-checkout git-cherry-pick git-clone git-commit git-diff git-fetch = git-format-patch git-grep git-log git-ls-remote git-merge git-mv git-octopu= s git-pull git-push git-rebase git-repack git-reset git-resolve git-revert = git-shortlog git-show-branch git-status git-verify-tag git-whatchanged git-= applypatch git-archimport git-archive git-convert-objects git-cvsimport git= -lost-found git-merge-one-file git-prune git-relink git-svnimport git-symbo= lic-ref git-tag git-update-ref git-check-ref-format git-cherry git-count-ob= jects git-daemon git-get-tar-commit-id git-mailinfo git-mailsplit git-patch= -id git-request-pull git-send-email git-stripspace +#compdef git git-annotate git-apply git-checkout-index git-clean git-commi= t-tree git-describe git-hash-object git-index-pack git-init-db git-merge-in= dex git-merge-tree git-mktag git-mktree git-pack-objects git-prune-packed g= it-read-tree git-remote git-unpack-objects git-update-index git-write-tree = git-cat-file git-diff-index git-diff-files git-diff-stages git-diff-tree gi= t-fsck-objects git-ls-files git-ls-tree git-quiltimport git-merge-base git-= name-rev git-rev-list git-show-index git-tar-tree git-unpack-file git-var g= it-verify-pack git-clone-pack git-fetch-pack git-http-fetch git-local-fetch= git-peek-remote git-receive-pack git-send-pack git-ssh-fetch git-ssh-uploa= d git-update-server-info git-upload-pack git-add git-am git-applymbox git-b= isect git-branch git-checkout git-cherry-pick git-clone git-commit git-diff= git-fetch git-format-patch git-grep git-log git-ls-remote git-merge git-mv= git-octopus git-pull git-push git-rebase git-repack git-reset git-resolve = git-revert git-shortlog git-show-branch git-status git-verify-tag git-whatc= hanged git-applypatch git-archimport git-archive git-convert-objects git-cv= simport git-lost-found git-merge-one-file git-prune git-relink git-svnimpor= t git-symbolic-ref git-tag git-update-ref git-check-ref-format git-cherry g= it-count-objects git-daemon git-get-tar-commit-id git-mailinfo git-mailspli= t git-patch-id git-request-pull git-send-email git-stripspace =20 # Commands not completed: # git-sh-setup @@ -151,6 +151,7 @@ 'rebase:rebases local commits to new upstream head' 'receive-pack:command invoked by send-pack to receive what is pushed t= o it' 'relink:hardlinks acommon objects in local repositories' + 'remote:manage set of tracked repositories' 'repack:packs unpacked objects in a repository' 'request-pull:generates a summary of pending changes' 'reset:resets current HEAD to the specified state' @@ -361,6 +362,47 @@ fi } =20 +_git-remote () { + local curcontext=3D$curcontext state line + declare -A opt_args + + _arguments -C \ + ':command:->command' \ + '*::options:->options' && ret=3D0 + + case $state in + (command) + declare -a commands + + commands=3D( + 'add:add a new remote' + 'show:show information about a given remote' + 'prune:delete all stale tracking branches for a given remote' + 'update:fetch updates for a set of remotes') + + _describe -t commands 'sub-command' commands && ret=3D0 + ;; + (options) + case $line[1] in + (add) + _arguments \ + '*'{--track,-t}'[track given branch instead of default glob re= fspec]:branch:__git_branch_names' \ + '(--master -m)'{--master,-m}"[set the remote's HEAD to point t= o given master branch]:branch:__git_branch_names" \ + '(--fetch -f)'{--fetch,-f}'[run git-fetch on the new remote af= ter it has been created]' \ + ':branch name:__git_remotes' \ + ':url:_urls' && ret=3D0 + ;; + (show|name|prune) + __git_remotes && ret=3D0 + ;; + (update) + __git_remote-groups && ret=3D0 + ;; + esac + ;; + esac +} + _git-unpack-objects () { _arguments \ '-n[only list the objects that would be unpacked]' \ @@ -1493,6 +1535,29 @@ 'remote repositories::__git_remote_repository' } =20 +__git_remotes () { + local expl gitdir remotes + + gitdir=3D$(_call_program gitdir git rev-parse --git-dir 2>/dev/null) + __git_command_successful || return + +# zparseopts -a opts X+: +# +# if (( !$opts[(I)-X] )); then +# descr=3Dremote +# fi + + remotes=3D(${${(f)"$(_call_program remotes git config --get-regexp '"^re= mote\..*\.url$"')"}//#(#b)remote.(*).url */$match[1]}) + __git_command_successful || return + + # TODO: Should combine the two instead of either or. + if (( $#remotes > 0 )); then + _wanted remotes expl remote compadd $* - $remotes + else + _wanted remotes expl remote _files $* - -W "($gitdir/remotes)" -g "$gi= tdir/remotes/*" + fi +} + __git_ref_specs () { if compset -P '*:'; then __git_heads @@ -1566,6 +1631,32 @@ fi } =20 +__git_branch_names () { + local expl + declare -a branch_names + + branch_names=3D(${${(f)"$(_call_program branch-names git branch 2>/dev/n= ull)"}#[* ] }) + __git_command_successful || return + + _wanted branch-names expl branch-name compadd $* - $branch_names +} + +__git_config_filtered_gettable_name () { + local expl + declare -a names + + # TODO: See __git_config_gettable_name for discussion on how to actually= get + # out the names, skipping the values. + names=3D(${${(M)${${(f)"$(_call_program $2 git config --list)"}%%\=3D*}:= #$1.*}#$1.}) + __git_command_successful || return + + _wanted $2 expl $3 compadd $names +} + +__git_remote-groups () { + __git_config_filtered_gettable_name 'remotes' remote-groups 'remote-grou= ps' +} + __git_local_references () { local expl =20