>From 12950b7b976a85e6d60a2df4213b98a50e5696c6 Mon Sep 17 00:00:00 2001 From: Dominik Vogt 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