diff options
| author | Peter Stephenson <pws@users.sourceforge.net> | 2005-11-25 12:52:23 +0000 |
|---|---|---|
| committer | Peter Stephenson <pws@users.sourceforge.net> | 2005-11-25 12:52:23 +0000 |
| commit | ab5111a5cb09eeeae0db356c261cf02c1a43755c (patch) | |
| tree | cebefef0e53c5747901795b9c0331cf693dd6ebe /Completion/Unix/Command | |
| parent | 22027: more zsh-newuser-install fixes (diff) | |
| download | zsh-ab5111a5cb09eeeae0db356c261cf02c1a43755c.tar zsh-ab5111a5cb09eeeae0db356c261cf02c1a43755c.tar.gz zsh-ab5111a5cb09eeeae0db356c261cf02c1a43755c.tar.bz2 zsh-ab5111a5cb09eeeae0db356c261cf02c1a43755c.tar.lz zsh-ab5111a5cb09eeeae0db356c261cf02c1a43755c.tar.xz zsh-ab5111a5cb09eeeae0db356c261cf02c1a43755c.tar.zst zsh-ab5111a5cb09eeeae0db356c261cf02c1a43755c.zip | |
22031: new git completion
Diffstat (limited to 'Completion/Unix/Command')
| -rw-r--r-- | Completion/Unix/Command/_git | 1348 |
1 files changed, 1348 insertions, 0 deletions
diff --git a/Completion/Unix/Command/_git b/Completion/Unix/Command/_git new file mode 100644 index 000000000..7b76d5a90 --- /dev/null +++ b/Completion/Unix/Command/_git @@ -0,0 +1,1348 @@ +#compdef git git-apply git-checkout-index git-commit-tree git-hash-object git-index-pack git-init-db git-merge-index git-mktag git-pack-objects git-prune-packed git-read-tree git-unpack-objects git-update-index git-write-tree git-cat-file git-diff-index git-diff-files git-diff-stages git-diff-tree git-fsck-objects git-ls-files git-ls-tree git-merge-base git-name-rev git-rev-list git-show-index git-tar-tree git-unpack-file git-var git-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-upload git-update-server-info git-upload-pack git-add git-am git-applymbox git-bisect 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-whatchanged git-applypatch git-archimport git-convert-objects git-cvsimport git-lost-found git-merge-one-file git-prune git-relink git-svnimport git-symbolic-ref git-tag git-update-ref git-check-ref-format git-cherry git-count-objects git-daemon git-get-tar-commit-id git-mailinfo git-mailsplit git-patch-id git-request-pull git-send-email git-stripspace + +# Commands not completed: +# git-sh-setup +# git-shell +# 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 +# GIT_DIR=... stuff as pre-command modifier) + +# TODO: suggested zstyles: +# +# zstyle ':completion::*:git-{name-rev,add,rm}:*' ignore-line true + +typeset -g nul_arg= + +nul_arg='-z[use NUL termination on output]' + +typeset -ga diff_args + +# TODO: -s and --diff-filter are undocumented +diff_args=( + '--diff-filter=-[filter to apply to diff]' + '--find-copies-harder[try harder to find copies]' + '--name-only[show only names of changed files]' + '--name-status[show only names and status of changed files]' + '--pickaxe-all[when -S finds a change, show all changes in that changeset]' + '-B-[break complete rewrite changes into pairs of given size]: :_guard "[[\:digit\:]]#" size' + '-C-[detect copies as well as renames with given score]: :_guard "[[\:digit\:]]#" size' + '-l-[number of rename/copy targets to run]: :_guard "[[\:digit\:]]#" number' + '-M-[detect renames with given score]: :_guard "[[\:digit\:]]#" size' + '-O-[output patch in the order of glob-pattern lines in given file]:file:_files' + '-p[generate diff in patch format]' + '-R[do a reverse diff]' + '-S-[look for differences that contain the given string]:string' + '-s[do not produce any output]' + '-u[synonym for -p]' + $nul_arg +) + +typeset -g pretty_arg= +pretty_arg='--pretty=-[pretty print commit messages]::pretty print:((raw\:"the raw commits" + medium\:"most parts of the messages" + short\:"few headers and only subject of messages" + full\:"all parts of the commit messages" + oneline\:"commit-ids and subject of messages"))' + +typeset -g exec_arg= +exec_arg='--exec=-[specify path to git-upload-pack on remote side]:remote path' + +typeset -ga fetch_args + +fetch_args=( + '-a[fetch all objects]' + '-c[fetch commit objects]' + '--recover[recover from a failed fetch]' + '-t[fetch trees associated with commit objects]' + '-v[show what is downloaded]' + '-w[write out the given commit-id to the given file]:new file' +) + +typeset -ga merge_strategy + +merge_strategy=( + '(-s --strategy)'{-s,--strategy=}'[use given merge strategy]:strategy:(octopus recursive resolve stupid)') + +typeset -ga force_ref_arg + +force_ref_arg=('(-f --force)'{-f,--force}'[allow refs that are not ancestors to be updated]') + +typeset -ga tags_fetch_arg + +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 +} + +# TODO: this needs to be cleaned up and fixed +local curcontext=$curcontext ret=1 + +if [[ $words[1] == git ]]; then + if (( CURRENT == 2 )); then + _git_commands + else + shift words + (( CURRENT-- )) + curcontext="${curcontext%:*:*}:git-$words[1]:" + _call_function ret _git-$words[1] + fi +else + _call_function ret _$words[1] +fi + +_git-apply () { + _arguments \ + $nul_arg \ + '*--apply[apply patches that would otherwise not be applied]' \ + '*--check[check if patches are applicable]' \ + '*--exclude=-[skip files matching specified pattern]:file pattern' \ + '*--index[make sure that the patch is applicable to the index]' \ + '*--index-info[output information about original version of a blob if available]' \ + '*--no-merge[do not use merge behavior]' \ + '*--numstat[same as --stat but in decimal notation and complete pathnames]' \ + '*--stat[output diffstat for the input]' \ + '*--summary[output summary of git-diff extended headers]' \ + '*:file:_files' && ret=0 +} + +_git-checkout-index () { + _arguments -S \ + '(-a --all :)'{-a,--all}'[check out all files in the index]' \ + '(-f --force)'{-f,--force}'[force overwrite of existing files]' \ + '(-n --no-create)'{-n,--no-create}'[do not checkout new files]' \ + '(-q --quiet)'{-q,--quiet}'[do not complain about existing files or missing files]' \ + '(-u --index)'{-u,--index}'[update stat information in index]' \ + '--prefix=-[prefix to use when creating files]:directory:_directories' \ + '*:file:_files' && ret=0 +} + +_git-commit-tree () { + if (( CURRENT == 2 )); then + __git_trees && ret=0 + elif [[ $words[CURRENT-1] == -p ]]; then + local expl + _description commits expl 'parent commit' + __git_objects $expl && ret=0 + else + compadd - '-p' + fi +} + +_git-hash-object () { + _arguments \ + '-t[the type of object to create]:object type:((blob\:"a blob of data" + commit\:"a tree with parent commits" + tag\:"a symbolic name for another object" + tree\:"a recursive tree of blobs"))' \ + '-w[write the object to the object database]' \ + ':file:_files' && ret=0 +} + +_git-index-pack () { + _arguments \ + '-o[write generated pack index into specified file]' \ + ':pack file:_files -g "*.pack"' && ret=0 +} + +_git-init-db () { + _arguments \ + '--template=-[directory to use as a template for the object database]:directory:_directories' && ret=0 +} + +_git-merge-index () { + if (( CURRENT > 2 )) && [[ $words[CURRENT-1] != -[oq] ]]; then + _arguments -S \ + '(:)-a[run merge against all files in the index that need merging]' \ + '*:index file:__git_files' && ret=0 + else + typeset -a arguments + + (( CURRENT == 2 )) && arguments+='-o[skip failed merges]' + (( CURRENT == 2 || CURRENT == 3 )) && arguments+='(-o)-q[do not complain about failed merges]' + (( 2 <= CURRENT && CURRENT <= 4 )) && arguments+='*:merge program:_files -g "*(*)"' + + _arguments -S $arguments && ret=0 + fi +} + +_git-mktag () { + _message 'no arguments allowed; only accepts tags on standard input' +} + +_git-pack-objects () { + _arguments \ + '--depth=-[maximum delta depth]' \ + '--incremental[ignore objects that have already been packed]' \ + '--non-empty[only create a package if it contains at least one object]' \ + '--local[similar to --incremental, but only ignore unpacked non-local objects]' \ + '--window=-[number of objects to use per delta compression]' \ + '(:)--stdout[write the pack to standard output]' \ + ':base-name:_files' && ret=0 +} + +_git-prune-packed () { + _arguments \ + '-n[only list the objects that would be removed]' && ret=0 +} + +_git-read-tree () { + if (( CURRENT == 2 )); then + _arguments \ + '--reset[perform a merge, not just a read, ignoring unmerged entries]' \ + '--trivial[only perform trivial merges]' \ + '-m[perform a merge, not just a read]' \ + ':tree-ish:__git_tree_ishs' && ret=0 + elif [[ $words[2] == (-m|--reset) ]]; then + _arguments \ + '-i[update only the index; ignore changes in work tree]' \ + '-u[update the work tree after successful merge]' \ + '2:first tree-ish to be read/merged:__git_tree_ishs' \ + '3:second tree-ish to be read/merged:__git_tree_ishs' \ + '4:third tree-ish to be read/merged:__git_tree_ishs' && ret=0 + else + _message 'no more arguments' + fi +} + +_git-unpack-objects () { + _arguments \ + '-n[only list the objects that would be unpacked]' \ + '-q[run quietly]' && ret=0 +} + +_git-update-index () { + local -a refreshables + + if (( $words[(I)--refresh] )); then |
