summaryrefslogtreecommitdiff
path: root/contrib/completion
AgeCommit message (Collapse)AuthorFilesLines
2013-05-03completion: zsh: don't override suffix on _detaultLibravatar Felipe Contreras1-1/+1
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-04-29Merge branch 'fc/zsh-completion' into maintLibravatar Junio C Hamano1-8/+126
* 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 cmdLibravatar Felipe Contreras1-1/+119
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 simplificationLibravatar Felipe Contreras1-8/+8
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 booleanLibravatar Ramkumar Ramachandra1-0/+4
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 listLibravatar Ramkumar Ramachandra1-0/+5
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.statGraphWidthLibravatar Ramkumar Ramachandra1-1/+1
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-26Merge branch 'fc/untracked-zsh-prompt' into maintLibravatar Junio C Hamano1-1/+1
* fc/untracked-zsh-prompt: prompt: fix untracked files for zsh
2013-04-24completion: remove duplicate block for "git commit -c"Libravatar Mårten Kongstad1-7/+0
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-21prompt: fix untracked files for zshLibravatar Felipe Contreras1-1/+1
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-03-31bash: teach __git_ps1 about REVERT_HEADLibravatar Robin Rosenberg1-0/+2
Signed-off-by: Robin Rosenberg <robin.rosenberg@dewire.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-03-11Merge branch 'mp/complete-paths'Libravatar Junio C Hamano1-5/+11
* mp/complete-paths: git-completion.bash: zsh does not implement function redirection correctly
2013-03-11git-completion.bash: zsh does not implement function redirection correctlyLibravatar Matthieu Moy1-5/+11
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'Libravatar Junio C Hamano1-0/+9
* mp/complete-paths: git-completion.zsh: define __gitcomp_file compatibility function
2013-03-05git-completion.zsh: define __gitcomp_file compatibility functionLibravatar Matthieu Moy1-0/+9
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-02-18shell-prompt: clean up nested if-thenLibravatar Martin Erik Werner1-14/+13
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'Libravatar Junio C Hamano1-1/+13
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'Libravatar Junio C Hamano1-3/+8
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 optionLibravatar Martin Erik Werner1-3/+8
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>
2013-02-12completion: support 'git config --local'Libravatar Matthieu Moy1-2/+2
This needs to be done in two places: __git_config_get_set_variables to allow clever completion of "git config --local --get foo<tab>", and _git_config to allow "git config --loc<tab>" to complete to --local. While we're there, change the order of options in the code to match git-config.txt. Signed-off-by: Matthieu Moy <Matthieu.Moy@imag.fr> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-02-08Merge branch 'mk/tcsh-complete-only-known-paths'Libravatar Junio C Hamano1-0/+12
The "complete with known paths only" update to completion scripts returns directory names without trailing slash to compensate the addition of '/' done by bash that reads from our completion result. tcsh completion code that reads from our internal completion result does not add '/', so let it ask our complletion code to keep the '/' at the end. * mk/tcsh-complete-only-known-paths: completion: handle path completion and colon for tcsh script
2013-02-08Merge branch 'mp/complete-paths'Libravatar Junio C Hamano1-15/+240
The completion script used to let the default completer to suggest pathnames, which gave too many irrelevant choices (e.g. "git add" would not want to add an unmodified path). Teach it to use a more git-aware logic to enumerate only relevant ones. * mp/complete-paths: git-completion.bash: add support for path completion
2013-02-03completion: handle path completion and colon for tcsh scriptLibravatar Marc Khouzam1-0/+12
Recent enhancements to git-completion.bash provide intelligent path completion for git commands. Such completions do not provide the '/' at the end of directories for recent versions of bash; instead, bash itself will add the trailing slash to directories to the result provided by git-completion.bash. However, the completion for tcsh uses the result of the bash completion script directly, so it either needs to add the necessary slash itself, or needs to ask the bash script to keep the trailing slash. Adding the slash itself is difficult because we have to check the each path in the output of the bash script to see if it is meant to be a directory or something else. For example, assuming there is a directory named 'commit' in the current directory, then, when completing git add commit<tab> we would need to add a slash, but for git help commit<tab> we should not. Figuring out such differences would require adding much intelligence to the tcsh completion script. Instead, it is simpler to ask the bash script to keep the trailing slash. This patch does this. Also, tcsh does not handle the colon as a completion separator so we remove it from the list of separators. Signed-off-by: Marc Khouzam <marc.khouzam@ericsson.com>
2013-02-01Merge branch 'jc/do-not-let-random-file-interfere-with-completion-tests'Libravatar Junio C Hamano1-1/+10
Scripts to test bash completion was inherently flaky as it was affected by whatever random things the user may have on $PATH. * jc/do-not-let-random-file-interfere-with-completion-tests: t9902: protect test from stray build artifacts
2013-01-28Merge branch 'bc/fix-array-syntax-for-3.0-in-completion-bash'Libravatar Junio C Hamano1-1/+1
Fix use of an array notation that older versions of bash do not understand. * bc/fix-array-syntax-for-3.0-in-completion-bash: git-completion.bash: replace zsh notation that breaks bash 3.X
2013-01-24t9902: protect test from stray build artifactsLibravatar Junio C Hamano1-1/+10
When you have random build artifacts in your build directory, left behind by running "make" while on another branch, the "git help -a" command run by __git_list_all_commands in the completion script that is being tested does not have a way to know that they are not part of the subcommands this build will ship. Such extra subcommands may come from the user's $PATH. They will interfere with the tests that expect a certain prefix to uniquely expand to a known completion. Instrument the completion script and give it a way for us to tell what (subset of) subcommands we are going to ship. Also add a test to "git --help <prefix><TAB>" expansion. It needs to show not just commands but some selected documentation pages. Based on an idea by Jeff King. Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-01-23Merge branch 'as/check-ignore'Libravatar Junio C Hamano1-0/+1
Add a new command "git check-ignore" for debugging .gitignore files. The variable names may want to get cleaned up but that can be done in-tree. * as/check-ignore: clean.c, ls-files.c: respect encapsulation of exclude_list_groups t0008: avoid brace expansion add git-check-ignore sub-command setup.c: document get_pathspec() add.c: extract new die_if_path_beyond_symlink() for reuse add.c: extract check_path_for_gitlink() from treat_gitlinks() for reuse pathspec.c: rename newly public functions for clarity add.c: move pathspec matchers into new pathspec.c for reuse add.c: remove unused argument from validate_pathspec() dir.c: improve docs for match_pathspec() and match_pathspec_depth() dir.c: provide clear_directory() for reclaiming dir_struct memory dir.c: keep track of where patterns came from dir.c: use a single struct exclude_list per source of excludes Conflicts: builtin/ls-files.c dir.c
2013-01-18git-completion.bash: replace zsh notation that breaks bash 3.XLibravatar Brandon Casey1-1/+1
When commit d8b45314 began separating the zsh completion from the bash completion, it introduced a zsh completion "bridge" section into the bash completion script for zsh users to use until they migrated to the zsh script. The zsh '+=()' append-to-array notation prevents bash 3.00.15 on CentOS 4.x from loading the completion script and breaks test 9902. We can easily work around this by using standard Bash array notation. Signed-off-by: Brandon Casey <drafnel@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-01-18Merge branch 'ds/completion-silence-in-tree-path-probe'Libravatar Junio C Hamano1-1/+1
An internal ls-tree call made by completion code only to probe if a path exists in the tree recorded in a commit object leaked error messages when the path is not there. It is not an error at all and should not be shown to the end user. * ds/completion-silence-in-tree-path-probe: git-completion.bash: silence "not a valid object" errors
2013-01-18Merge branch 'mk/complete-tcsh'Libravatar Junio C Hamano1-12/+21
Update tcsh command line completion so that an unwanted space is not added to a single directory name. * mk/complete-tcsh: Prevent space after directories in tcsh completion
2013-01-16diff: Introduce --diff-algorithm command line optionLibravatar Michal Privoznik1-0/+11
Since command line options have higher priority than config file variables and taking previous commit into account, we need a way how to specify myers algorithm on command line. However, inventing `--myers` is not the right answer. We need far more general option, and that is `--diff-algorithm`. Signed-off-by: Michal Privoznik <mprivozn@redhat.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-01-16config: Introduce diff.algorithm variableLibravatar Michal Privoznik1-0/+1
Some users or projects prefer different algorithms over others, e.g. patience over myers or similar. However, specifying appropriate argument every time diff is to be used is impractical. Moreover, creating an alias doesn't play nicely with other tools based on diff (git-show for instance). Hence, a configuration variable which is able to set specific algorithm is needed. For now, these four values are accepted: 'myers' (which has the same effect as not setting the config variable at all), 'minimal', 'patience' and 'histogram'. Signed-off-by: Michal Privoznik <mprivozn@redhat.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-01-14git-completion.bash: Autocomplete --minimal and --histogram for git-diffLibravatar Michal Privoznik1-1/+1
Even though --patience was already there, we missed --minimal and --histogram for some reason. Signed-off-by: Michal Privoznik <mprivozn@redhat.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-01-14Merge branch 'jk/complete-commit-c' into maintLibravatar Junio C Hamano1-0/+7
* jk/complete-commit-c: completion: complete refs for "git commit -c"
2013-01-11git-completion.bash: add support for path completionLibravatar Manlio Perillo1-15/+240
The git-completion.bash script did not implemented full, git aware, support to complete paths, for git commands that operate on files within the current working directory or the index. As an example: git add <TAB> will suggest all files in the current working directory, including ignored files and files that have not been modified. Support path completion, for git commands where the non-option arguments always refer to paths within the current working directory or the index, as follows: * the path completion for the "git rm" and "git ls-files" commands will suggest all cached files. * the path completion for the "git add" command will suggest all untracked and modified files. Ignored files are excluded. * the path completion for the "git clean" command will suggest all untracked files. Ignored files are excluded. * the path completion for the "git mv" command will suggest all cached files when expanding the first argument, and all untracked and cached files for subsequent arguments. In the latter case, empty directories are included and ignored files are excluded. * the path completion for the "git commit" command will suggest all files that have been modified from the HEAD, if HEAD exists, otherwise it will suggest all cached files. For all affected commands, completion will always stop at directory boundary. Only standard ignored files are excluded, using the --exclude-standard option of the ls-files command. When using a recent Bash version, Git path completion will be the same as builtin file completion, e.g. git add contrib/ will suggest relative file names. Signed-off-by: Manlio Perillo <manlio.perillo@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-01-11git-completion.bash: silence "not a valid object" errorsLibravatar Dylan Smith1-1/+1
Trying to complete the command git show master:./file would cause a "Not a valid object name" error to be output on standard error. Silence the error so it won't appear on the command line. Signed-off-by: Dylan Smith <dylan.ah.smith@gmail.com> Reviewed-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-01-07Prevent space after directories in tcsh completionLibravatar Marc Khouzam1-12/+21
If git-completion.bash returns a single directory as a completion, tcsh will automatically add a space after it, which is not what the user wants. This commit prevents tcsh from doing this. Also, a check is added to make sure the tcsh version used is recent enough to allow completion to work as expected. Signed-off-by: Marc Khouzam <marc.khouzam@ericsson.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-01-06add git-check-ignore sub-commandLibravatar Adam Spiers1-0/+1
This works in a similar manner to git-check-attr. Thanks to Jeff King and Junio C Hamano for the idea: http://thread.gmane.org/gmane.comp.version-control.git/108671/focus=108815 Signed-off-by: Adam Spiers <git@adamspiers.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-01-05Merge branch 'jk/complete-commit-c'Libravatar Junio C Hamano1-0/+7
Complete "git commmit -c foo<TAB>" into a refname that begins with "foo". * jk/complete-commit-c: completion: complete refs for "git commit -c"
2012-12-27Merge branch 'so/prompt-command'Libravatar Junio C Hamano1-12/+20
Finishing touches... * so/prompt-command: make __git_ps1 accept a third parameter in pcmode
2012-12-26make __git_ps1 accept a third parameter in pcmodeLibravatar Simon Oosthoek1-12/+20
The optional third parameter when __git_ps1 is used in PROMPT_COMMAND mode as format string for printf to further customize the way the git status string is embedded in the user's PS1 prompt. Signed-off-by: Simon Oosthoek <s.oosthoek@xs4all.nl> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-12-15completion: complete refs for "git commit -c"Libravatar Jeff King1-0/+7
The "-c" and "-C" options take an existing commit, so let's complete refs, just as we would for --squash or --fixup. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-12-12Merge branch 'so/prompt-command'Libravatar Junio C Hamano1-5/+11
* so/prompt-command: git-prompt.sh: update PROMPT_COMMAND documentation
2012-12-12git-prompt.sh: update PROMPT_COMMAND documentationLibravatar Junio C Hamano1-5/+11
The description of __git_ps1 function operating in two-arg mode was not very clear. It said "set PROMPT_COMMAND=__git_ps1" which is not the right usage for this mode, followed by "To customize the prompt, do this", giving a false impression that those who do not want to customize it can get away with no-arg form, which was incorrect. Make it clear that this mode always takes two arguments, pre and post, with an example. The straight-forward one should be listed as the primary usage, and the confusing one should be an alternate for advanced users. Swap the order of these two. Acked-by: Simon Oosthoek <s.oosthoek@xs4all.nl> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-12-11Add file completion to tcsh git completion.Libravatar Marc Khouzam1-15/+54
For bash completion, the option '-o bashdefault' is used to indicate that when no other choices are available, file completion should be performed. Since this option is not available in tcsh, no file completion is ever performed. Therefore, commands like 'git add ', 'git send-email ', etc, require the user to manually type out the file name. This can be quite annoying. To improve the user experience we try to simulate file completion directly in this script (although not perfectly). The known issues with the file completion simulation are: - Possible completions are shown with their directory prefix. - Completions containing shell variables are not handled. - Completions with ~ as the first character are not handled. Signed-off-by: Marc Khouzam <marc.khouzam@ericsson.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-12-11Merge branch 'maint'Libravatar Junio C Hamano1-1/+10
* maint: git-prompt: Document GIT_PS1_DESCRIBE_STYLE
2012-12-11git-prompt: Document GIT_PS1_DESCRIBE_STYLELibravatar Anders Kaseorg1-0/+9
GIT_PS1_DESCRIBE_STYLE was introduced in v1.6.3.2~35. Document it in the header comments. Signed-off-by: Anders Kaseorg <andersk@mit.edu> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-11-29Merge branch 'mk/complete-tcsh'Libravatar Junio C Hamano1-7/+12
Finishing touches for tcsh completion. * mk/complete-tcsh: Support for git aliasing for tcsh completion
2012-11-29completion: fix warning for zshLibravatar Felipe Contreras1-0/+2
Otherwise the user might get something like: git-completion.sh:2466: command not found: compdef If this script is loaded before compinit. The script would work either way, but let's not be more annoying to the user. Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2012-11-28Merge branch 'maint'Libravatar Junio C Hamano1-0/+2