summaryrefslogtreecommitdiff
path: root/contrib/completion
AgeCommit message (Collapse)Author
2013-05-17prompt: colorize ZSH promptRamkumar Ramachandra
Add colors suitable for use in the ZSH prompt. Having learnt that the ZSH equivalent of PROMPT_COMMAND is precmd (), you can now use GIT_PS1_SHOWCOLORHINTS with ZSH. Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-05-17prompt: factor out gitstring coloring logicRamkumar Ramachandra
So that we can extend it with ZSH-colors in a later patch. Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-05-17prompt: introduce GIT_PS1_STATESEPARATORRamkumar Ramachandra
A typical prompt looks like: artagnon|master *=:~/src/git$ ^ why do we have this space? Nobody has branch names that end with +, *, =, < or > anyway, so it doesn't serve the purpose of disambiguation. Make this separator configurable via GIT_PS1_STATESEPARATOR. This means that you can set it to "" and get this prompt: artagnon|master*=:~/src/git$ Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-05-09git-svn: added an --include-path flagPaul Walmsley
The SVN::Fetcher module is now able to filter for inclusion as well as exclusion (as used by --ignore-path). Also added tests, documentation changes and git completion script. If you have an SVN repository with many top level directories and you only want a git-svn clone of some of them then using --ignore-path is difficult as it requires a very long regexp. In this case it's much easier to filter for inclusion. [ew: remove trailing whitespace] Signed-off-by: Paul Walmsley <pjwhams@gmail.com> Signed-off-by: Eric Wong <normalperson@yhbt.net>
2013-05-08completion: synchronize zsh wrapperFelipe Contreras
So it's closer to the full zsh wrapper. Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-05-08completion: cleanup zsh wrapperFelipe Contreras
There's no need for a separate function; we can call 'emulate -k ksh func'. Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-05-03Sync with maintJunio C Hamano
* maint: completion: zsh: don't override suffix on _detault Documentation/git-commit: Typo under --edit
2013-05-03completion: zsh: don't override suffix on _detaultFelipe Contreras
zsh is smart enough to add the right suffix while completing, there's no point in trying to do the same as bash. Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-05-01Merge branch 'zk/prompt-rebase-step'Junio C Hamano
* zk/prompt-rebase-step: bash-prompt.sh: show where rebase is at when stopped
2013-04-29git-completion.bash: add remote.pushdefault to config listRamkumar Ramachandra
224c2171 (remote.c: introduce remote.pushdefault, 2013-04-02) introduced the remote.pushdefault configuration variable, but forgot to teach git-completion.bash about it. Fix this. Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-04-29git-completion.bash: add branch.*.pushremote to config listRamkumar Ramachandra
9f765ce (remote.c: introduce branch.<name>.pushremote, 2013-04-02) introduced the configuration variable branch.*.pushremote, but forgot to teach git-completion.bash about it. Fix this. Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-04-29Merge branch 'maint'Junio C Hamano
* maint: complete: zsh: use zsh completion for the main cmd complete: zsh: trivial simplification git-completion.bash: complete branch.*.rebase as boolean git-completion.bash: add diff.submodule to config list git-completion.bash: lexical sorting for diff.statGraphWidth
2013-04-29Merge branch 'fc/zsh-completion' into maintJunio C Hamano
* fc/zsh-completion: complete: zsh: use zsh completion for the main cmd complete: zsh: trivial simplification
2013-04-29complete: zsh: use zsh completion for the main cmdFelipe Contreras
So that we can have a nice zsh completion output: % git <tab> add -- add file contents to the index bisect -- find by binary search the change that introduced a bug branch -- list, create, or delete branches checkout -- checkout a branch or paths to the working tree clone -- clone a repository into a new directory commit -- record changes to the repository diff -- show changes between commits, commit and working tree, etc fetch -- download objects and refs from another repository grep -- print lines matching a pattern init -- create an empty Git repository or reinitialize an existing one log -- show commit logs merge -- join two or more development histories together mv -- move or rename a file, a directory, or a symlink pull -- fetch from and merge with another repository or a local branch push -- update remote refs along with associated objects rebase -- forward-port local commits to the updated upstream head reset -- reset current HEAD to the specified state rm -- remove files from the working tree and from the index show -- show various types of objects status -- show the working tree status tag -- create, list, delete or verify a tag object signed with GPG And other niceties, like 'git --git-dir=<tab>' showing only directories. For the rest, the bash completion stuff is still used. Also, add my copyright, since this more than a thin wrapper. Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-04-29complete: zsh: trivial simplificationFelipe Contreras
There should be no functional changes. The only reason I wrapped this code around a sub-function is because zsh did the same in it's bashcompinit script in order to declare the special variable 'words' as hidden, but only in this context. There's no need for that any more since we access __git_main directly, so 'words' is not modified, so there's no need for the sub-function. In zsh mode the array indexes are different though. Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-04-29git-completion.bash: complete branch.*.rebase as booleanRamkumar Ramachandra
6fac1b83 (completion: add missing config variables, 2009-06-29) added "rebase" to the list of completions for "branch.*.*", but forgot to specify completions for the values that this configuration variable can take (namely "false" and "true"). Fix this. Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-04-29git-completion.bash: add diff.submodule to config listRamkumar Ramachandra
c47ef57 (diff: introduce diff.submodule configuration variable, 2012-11-13) introduced the diff.submodule configuration variable, but forgot to teach git-completion.bash about it. Fix this. Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-04-29git-completion.bash: lexical sorting for diff.statGraphWidthRamkumar Ramachandra
df44483a (diff --stat: add config option to limit graph width, 2012-03-01) added the option diff.startGraphWidth to the list of configuration variables in git-completion.bash, but failed to notice that the list is sorted alphabetically. Move it to its rightful place in the list. Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-04-27completion: add missing format-patch optionsFelipe Contreras
Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-04-27completion: remove __git_index_file_list_filter()Felipe Contreras
Refactor the code into the only caller; __git_index_files(). Also, Somehow messing up with the 'path' variable messes up the 'PATH' variable. So let's not do that. Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-04-27completion: add space after completed filenameFelipe Contreras
Just like before fea16b4 (git-completion.bash: add support for path completion). Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-04-27completion: add hack to enable file mode in bash < 4Felipe Contreras
This way we don't need all the compat stuff, different filters, and so on. Also, now we complete exactly the same in bash 3 and bash 4. This is the way bash-completion did it for quite some time, when bash 3 was supported. For more information about the hack: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=272660#64 Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-04-27completion: refactor __git_complete_index_file()Felipe Contreras
The calls to __gitcomp_file() are essentially the same, but with different prefix. Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-04-27completion: refactor diff_index wrappersFelipe Contreras
At the end of the day what we really need is to find out the files that have been staged, or modified, because those files are the ones that make sense to pass as arguments to 'git commit'. We need diff-index to find those out, since 'git ls-files' doesn't do that. But we don't need wrappers and wrappers basically identical to the ones used for 'git ls-files', when we can pretend it receives a --committable option that would return what we need. That way, we can remove a bunch of code without any functional changes. Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-04-27completion: use __gitcompadd for __gitcomp_fileFelipe Contreras
Like the rest of the script does; let's not access COMPREPLY directly. Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-04-27completion; remove unuseful commentsFelipe Contreras
The only caller, __git_complete_index_file() doesn't specify any limits to the options for 'git ls-files', neither should this function. Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-04-26Merge branch 'fc/untracked-zsh-prompt' into maintJunio C Hamano
* fc/untracked-zsh-prompt: prompt: fix untracked files for zsh
2013-04-25bash-prompt.sh: show where rebase is at when stoppedZoltan Klinger
When a rebase stops (e.g. interrupted by a merge conflict), it could be useful to know how far a rebase has progressed and how many commits in total this rebase will apply. Teach the __git_ps1() command to display the number of commits so far applied and the total number of commits to be applied, like this: ((3ec0a6a...)|REBASE 2/5) In the example above the rebase has stopped at the second commit due to a merge conflict and there are a total number of five commits to be applied by this rebase. This information can be already obtained from the following files which are being generated during the rebase: GIT_DIR/.git/rebase-merge/msgnum (git-rebase--merge.sh) GIT_DIR/.git/rebase-merge/end (git-rebase--merge.sh) GIT_DIR/.git/rebase-apply/next (git-am.sh) GIT_DIR/.git/rebase-apply/last (git-am.sh) but "rebase -i" does not leave necessary clues. Implement this feature by doing these three things: 1) Modify git-rebase--interactive.sh to also create GIT_DIR/.git/rebase-merge/msgnum GIT_DIR/.git/rebase-merge/end files for the number of commits so far applied and the total number of commits to be applied. 2) Modify git-prompt.sh to read and display info from the above files. 3) Update test t9903-bash-prompt.sh to reflect changes introduced by this patch. Signed-off-by: Zoltan Klinger <zoltan.klinger@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-04-24Sync with maintJunio C Hamano
* maint: Update draft release notes to 1.8.2.2 completion: remove duplicate block for "git commit -c" cherry-pick/revert: make usage say '<commit-ish>...'
2013-04-24completion: remove duplicate block for "git commit -c"Mårten Kongstad
Remove one of two consecutive, identical blocks for "git commit -c". This was caused by a mechanical mismerge at d931e2fb252e (Merge branch 'mp/complete-paths', 2013-02-08). The side branch wanted to add this block at fea16b47 but the same fix was done independently at 685397585 already. Signed-off-by: Mårten Kongstad <marten.kongstad@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-04-23Merge branch 'fc/untracked-zsh-prompt'Junio C Hamano
* fc/untracked-zsh-prompt: prompt: fix untracked files for zsh
2013-04-22prompt: fix untracked files for zshFelipe Contreras
We signal presense of untracked files by adding a per-cent sign '%' to the prompt. But because '%' is used as an escape character to introduce prompt customization in zsh (just like bash prompt uses '\' to escape '\u', '\h', etc.), we need to say '%%' to get a literal per-cent. Helped-by: Andreas Schwab <schwab@linux-m68k.org> Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-04-15completion: small optimizationFelipe Contreras
No need to calculate a new $c with a space if we are not going to do anything it with it. There should be no functional changes, except that a word "foo " with no suffixes can't be matched. But $cur cannot have a space at the end anyway. So it's safe. Based on the code from SZEDER Gábor. Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-04-15completion: inline __gitcomp_1 to its sole callsiteFelipe Contreras
There is no point in calling a separate function that is only used in one place. Especially considering that there's no need to call compgen, and we traverse the words ourselves both in __gitcompadd, and __gitcomp_1. Let's squash the functions together, and traverse only once. This improves performance. For N number of words: == 1 == original: 0.002s new: 0.000s == 10 == original: 0.005s new: 0.001s == 100 == original: 0.009s new: 0.006s == 1000 == original: 0.027s new: 0.019s == 10000 == original: 0.163s new: 0.151s == 100000 == original: 1.555s new: 1.497s No functional changes. Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-04-15completion: get rid of compgenFelipe Contreras
The functionality we use from compgen is not much, we can do the same manually, with drastic improvements in speed, especially when dealing with only a few words. This patch also has the sideffect that brekage reported by Jeroen Meijer and SZEDER Gábor gets fixed because we no longer expand the resulting words. Here are some numbers filtering N amount of words: == 1 == original: 0.002s new: 0.000s == 10 == original: 0.002s new: 0.000s == 100 == original: 0.003s new: 0.002s == 1000 == original: 0.012s new: 0.011s == 10000 == original: 0.056s new: 0.066s == 100000 == original: 2.669s new: 0.622s If the results are not narrowed: == 1 == original: 0.002s new: 0.000s == 10 == original: 0.002s new: 0.001s == 100 == original: 0.004s new: 0.004s == 1000 == original: 0.020s new: 0.015s == 10000 == original: 0.101s new: 0.355s == 100000 == original: 2.850s new: 31.941s So, unless 'git checkout <tab>' usually gives you more than 10000 results, you'll get an improvement :) Other possible solutions perform better after 1000 words, but worst if less than that: COMPREPLY=($(awk -v cur="$3" -v pre="$2" -v suf="$4" '$0 ~ cur { print pre$0suf }' <<< "$1" )) COMPREPLY=($(printf -- "$2%s$4\n" $1 | grep "^$2$3")) Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-04-15completion: add new __gitcompadd helperFelipe Contreras
The idea is to never touch the COMPREPLY variable directly. This allows other completion systems (i.e. zsh) to override __gitcompadd, and do something different instead. Also, this allows further optimizations down the line. There should be no functional changes. Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-04-12completion: get rid of empty COMPREPLY assignmentsFelipe Contreras
There's no functional reason for those, the only purpose they are supposed to serve is to say "we don't provide any words here", but even for that it's not used consistently. Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-04-12completion: add more cherry-pick optionsFelipe Contreras
Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-04-03Merge branch 'rr/prompt-revert-head'Junio C Hamano
The prompt string generator did not notice when we are in a middle of a "git revert" session. * rr/prompt-revert-head: bash: teach __git_ps1 about REVERT_HEAD
2013-04-01bash: teach __git_ps1 about REVERT_HEADRobin Rosenberg
Signed-off-by: Robin Rosenberg <robin.rosenberg@dewire.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-03-25Merge branch 'jl/submodule-deinit'Junio C Hamano
There was no Porcelain way to say "I no longer am interested in this submodule", once you express your interest in a submodule with "submodule init". "submodule deinit" is the way to do so. * jl/submodule-deinit: submodule: add 'deinit' command
2013-03-11Merge branch 'mp/complete-paths'Junio C Hamano
* mp/complete-paths: git-completion.bash: zsh does not implement function redirection correctly
2013-03-11git-completion.bash: zsh does not implement function redirection correctlyMatthieu Moy
A recent change added functions whose entire standard error stream is redirected to /dev/null using a construct that is valid POSIX.1 but is not widely used: funcname () { cd "$1" && run some command "$2" } 2>/dev/null Even though this file is "git-completion.bash", zsh completion support dot-sources it (instead of asking bash to grok it like tcsh completion does), and zsh does not implement this redirection correctly. With zsh, trying to complete an inexistant directory gave this: git add no-such-dir/__git_ls_files_helper:cd:2: no such file or directory: no-such-dir/ Also these functions use "cd" to first go somewhere else before running a command, but the location the caller wants them to go that is given as an argument to them should not be affected by CDPATH variable the users may have set for their interactive session. To fix both of these, wrap the body of the function in a subshell, unset CDPATH at the beginning of the subshell, and redirect the standard error stream of the subshell to /dev/null. Signed-off-by: Matthieu Moy <Matthieu.Moy@imag.fr> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-03-07Merge branch 'mp/complete-paths'Junio C Hamano
* mp/complete-paths: git-completion.zsh: define __gitcomp_file compatibility function
2013-03-05git-completion.zsh: define __gitcomp_file compatibility functionMatthieu Moy
Commit fea16b47b60 (Fri Jan 11 19:48:43 2013, Manlio Perillo, git-completion.bash: add support for path completion), introduced a new __gitcomp_file function that uses the bash builtin "compgen". The function was redefined for ZSH in the deprecated section of git-completion.bash, but not in the new git-completion.zsh script. As a result, users of git-completion.zsh trying to complete "git add fo<tab>" get an error: git add fo__gitcomp_file:8: command not found: compgen This patch adds the redefinition and removes the error. Signed-off-by: Matthieu Moy <Matthieu.Moy@imag.fr> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-03-04submodule: add 'deinit' commandJens Lehmann
With "git submodule init" the user is able to tell git he cares about one or more submodules and wants to have it populated on the next call to "git submodule update". But currently there is no easy way he could tell git he does not care about a submodule anymore and wants to get rid of his local work tree (except he knows a lot about submodule internals and removes the "submodule.$name.url" setting from .git/config together with the work tree himself). Help those users by providing a 'deinit' command. This removes the whole submodule.<name> section from .git/config (either for the given submodule(s) or for all those which have been initialized if '.' is used) together with their work tree. Fail if the current work tree contains modifications (unless forced), but don't complain when either the work tree is already removed or no settings are found in .git/config. Add tests and link the man pages of "git submodule deinit" and "git rm" to assist the user in deciding whether removing or unregistering the submodule is the right thing to do for him. Also add the deinit subcommand to the completion list. Signed-off-by: Jens Lehmann <Jens.Lehmann@web.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-02-18shell-prompt: clean up nested if-thenMartin Erik Werner
Minor clean up of if-then nesting in checks for environment variables and config options. No functional changes. Signed-off-by: Martin Erik Werner <martinerikwerner@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-02-17Merge branch 'mp/diff-algo-config'Junio C Hamano
Add diff.algorithm configuration so that the user does not type "diff --histogram". * mp/diff-algo-config: diff: Introduce --diff-algorithm command line option config: Introduce diff.algorithm variable git-completion.bash: Autocomplete --minimal and --histogram for git-diff
2013-02-17Merge branch 'mw/bash-prompt-show-untracked-config'Junio C Hamano
Allows skipping the untracked check GIT_PS1_SHOWUNTRACKEDFILES asks for the git-prompt (in contrib/) per repository. * mw/bash-prompt-show-untracked-config: t9903: add extra tests for bash.showDirtyState t9903: add tests for bash.showUntrackedFiles shell prompt: add bash.showUntrackedFiles option
2013-02-13shell prompt: add bash.showUntrackedFiles optionMartin Erik Werner
Add a config option 'bash.showUntrackedFiles' which allows enabling the prompt showing untracked files on a per-repository basis. This is useful for some repositories where the 'git ls-files ...' command may take a long time. Signed-off-by: Martin Erik Werner <martinerikwerner@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>