summaryrefslogtreecommitdiff
path: root/contrib/completion
AgeCommit message (Collapse)AuthorFilesLines
2014-09-19Merge branch 'tb/complete-diff-ignore-blank-lines'Libravatar Junio C Hamano1-2/+2
* tb/complete-diff-ignore-blank-lines: completion: Add --ignore-blank-lines for diff
2014-09-09Merge branch 'jk/prompt-stash-could-be-packed'Libravatar Junio C Hamano1-1/+2
The prompt script checked $GIT_DIR/ref/stash file to see if there is a stash, which was a no-no. * jk/prompt-stash-could-be-packed: git-prompt: do not look for refs/stash in $GIT_DIR
2014-09-03completion: Add --ignore-blank-lines for diffLibravatar Thomas Braun1-2/+2
Signed-off-by: Thomas Braun <thomas.braun@virtuell-zuhause.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2014-08-25git-prompt: do not look for refs/stash in $GIT_DIRLibravatar Jeff King1-1/+2
Since dd0b72c (bash prompt: use bash builtins to check stash state, 2011-04-01), git-prompt checks whether we have a stash by looking for $GIT_DIR/refs/stash. Generally external programs should never do this, because they would miss packed-refs. That commit claims that packed-refs does not pack refs/stash, but that is not quite true. It does pack the ref, but due to a bug, fails to prune the ref. When we fix that bug, we would want to be doing the right thing here. Signed-off-by: Jeff King <peff@peff.net> Reviewed-by: Michael Haggerty <mhagger@alum.mit.edu> Reviewed-by: Ronnie Sahlberg <sahlberg@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2014-07-30Merge branch 'jk/more-push-completion'Libravatar Junio C Hamano1-1/+27
* jk/more-push-completion: completion: complete `git push --force-with-lease=` completion: add some missing options to `git push` completion: complete "unstuck" `git push --recurse-submodules`
2014-07-22completion: complete `git push --force-with-lease=`Libravatar John Keeping1-1/+21
Signed-off-by: John Keeping <john@keeping.me.uk> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2014-07-22completion: add some missing options to `git push`Libravatar John Keeping1-0/+1
Signed-off-by: John Keeping <john@keeping.me.uk> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2014-07-22completion: complete "unstuck" `git push --recurse-submodules`Libravatar John Keeping1-0/+5
Since the argument to `--recurse-submodules` is mandatory, it does not need to be stuck to the option with `=`. Signed-off-by: John Keeping <john@keeping.me.uk> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2014-06-25Merge branch 'sp/complete-ext-alias'Libravatar Junio C Hamano1-0/+10
* sp/complete-ext-alias: completion: handle '!f() { ... }; f' and "!sh -c '...' -" aliases
2014-06-13completion: handle '!f() { ... }; f' and "!sh -c '...' -" aliasesLibravatar Steffen Prohaska1-0/+10
'!f() { ... }; f' and "!sh -c '....' -" are recommended patterns for declaring more complex aliases (see git wiki [1]). This commit teaches the completion to handle them. When determining which completion to use for an alias, an opening brace or single quote is now skipped, and the search for a git command is continued. For example, the aliases '!f() { git commit ... }' or "!sh -c 'git commit ...'" now trigger commit completion. Previously, the search stopped on the opening brace or quote, and the completion tried it to determine how to complete, which obviously was useless. The null command ':' is now skipped, so that it can be used as a workaround to declare the desired completion style. For example, the aliases !f() { : git commit ; if ... } f !sh -c ': git commit; if ...' - now trigger commit completion. Shell function declarations now work with or without space before the parens, i.e. '!f() ...' and '!f () ...' both work. [1] https://git.wiki.kernel.org/index.php/Aliases Signed-off-by: Steffen Prohaska <prohaska@zib.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2014-05-27completion: add missing options for git-mergeLibravatar John Keeping1-1/+4
The options added to __git_merge_options are those that git-pull passes to git-merge, since that variable is used by both commands. Those added directly in _git_merge() are specific to git-merge and are not passed thru from git-pull. Reported-by: Haralan Dobrev <hkdobrev@gmail.com> Signed-off-by: John Keeping <john@keeping.me.uk> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2014-05-27completion: add a note that merge options are sharedLibravatar John Keeping1-0/+1
This should avoid future confusion after a subsequent patch has added some options to __git_merge_options and some directly in _git_merge(). Signed-off-by: John Keeping <john@keeping.me.uk> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2014-05-19Merge branch 'rh/prompt-pcmode-avoid-eval-on-refname'Libravatar Junio C Hamano1-17/+39
* rh/prompt-pcmode-avoid-eval-on-refname: git-prompt.sh: don't assume the shell expands the value of PS1
2014-05-19git-prompt.sh: don't assume the shell expands the value of PS1Libravatar Richard Hansen1-17/+39
Not all shells subject the prompt string to parameter expansion. Test whether the shell will expand the value of PS1, and use the result to control whether raw ref names are included directly in PS1. This fixes a regression introduced in commit 8976500 ("git-prompt.sh: don't put unsanitized branch names in $PS1"): zsh does not expand PS1 by default, but that commit assumed it did. The bug resulted in prompts containing the literal string '${__git_ps1_branch_name}' instead of the actual branch name. Reported-by: Caleb Thompson <caleb@calebthompson.io> Signed-off-by: Richard Hansen <rhansen@bbn.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2014-05-13Merge branch 'fc/prompt-zsh-read-from-file'Libravatar Junio C Hamano1-8/+8
* fc/prompt-zsh-read-from-file: contrib: completion: fix 'eread()' namespace
2014-05-13contrib: completion: fix 'eread()' namespaceLibravatar Felipe Contreras1-8/+8
Otherwise it might collide with a function of the same name in the user's environment. Suggested-by: SZEDER Gábor <szeder@ira.uka.de> Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2014-05-02Merge branch 'rh/prompt-pcmode-avoid-eval-on-refname'Libravatar Junio C Hamano1-2/+32
* rh/prompt-pcmode-avoid-eval-on-refname: git-prompt.sh: don't put unsanitized branch names in $PS1
2014-04-22git-prompt.sh: don't put unsanitized branch names in $PS1Libravatar Richard Hansen1-2/+32
Both bash and zsh subject the value of PS1 to parameter expansion, command substitution, and arithmetic expansion. Rather than include the raw, unescaped branch name in PS1 when running in two- or three-argument mode, construct PS1 to reference a variable that holds the branch name. Because the shells do not recursively expand, this avoids arbitrary code execution by specially-crafted branch names such as '$(IFS=_;cmd=sudo_rm_-rf_/;$cmd)'. Signed-off-by: Richard Hansen <rhansen@bbn.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2014-04-18Merge branch 'fc/complete-aliased-push'Libravatar Junio C Hamano2-0/+2
* fc/complete-aliased-push: completion: fix completing args of aliased "push", "fetch", etc.
2014-04-14prompt: fix missing file errors in zshLibravatar Felipe Contreras1-7/+14
zsh seems to have a bug while redirecting the stderr of the 'read' command: % read foo 2>/dev/null <foo zsh: no such file or directory: foo Which causes errors to be displayed when certain files are missing. Let's add a convenience function to manually check if the file is readable before calling "read". Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2014-04-09completion: fix completing args of aliased "push", "fetch", etc.Libravatar Felipe Contreras2-0/+2
Some commands need the first word to determine the actual action that is being executed, however, the command is wrong when we use an alias, for example 'alias.p=push', if we try to complete 'git p origin ', the result would be wrong because __git_complete_remote_or_refspec() doesn't know where it came from. So let's override words[1], so the alias 'p' is override by the actual command, 'push'. Reported-by: Aymeric Beaumet <aymeric.beaumet@gmail.com> Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2014-03-14Merge branch 'ss/completion-rec-sub-fetch-push'Libravatar Junio C Hamano1-1/+18
* ss/completion-rec-sub-fetch-push: completion: teach --recurse-submodules to fetch, pull and push
2014-02-11completion: teach --recurse-submodules to fetch, pull and pushLibravatar Sup Yut Sum1-1/+18
Signed-off-by: Sup Yut Sum <ch3cooli@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2014-01-27Merge branch 'jk/complete-merge-base'Libravatar Junio C Hamano1-1/+7
* jk/complete-merge-base: completion: handle --[no-]fork-point options to git-rebase completion: complete merge-base options
2014-01-13completion: handle --[no-]fork-point options to git-rebaseLibravatar John Keeping1-1/+1
Signed-off-by: John Keeping <john@keeping.me.uk> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2014-01-13completion: complete merge-base optionsLibravatar John Keeping1-0/+6
Signed-off-by: John Keeping <john@keeping.me.uk> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2014-01-13Merge branch 'rr/completion-format-coverletter'Libravatar Junio C Hamano1-0/+1
The bash/zsh completion code did not know about format.coverLetter among many format.* configuration variables. * rr/completion-format-coverletter: completion: complete format.coverLetter
2014-01-07completion: complete format.coverLetterLibravatar Ramkumar Ramachandra1-0/+1
Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2014-01-06completion: fix remote.pushdefaultLibravatar Ramkumar Ramachandra1-0/+1
When attempting to complete $ git config remote.push<TAB> 'pushdefault' doesn't come up. This is because "$cur" is matched with "remote.*" and a list of remotes are completed. Add 'pushdefault' as a candidate for completion too, using __gitcomp_nl_append (). Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2014-01-06completion: fix branch.autosetup(merge|rebase)Libravatar Ramkumar Ramachandra1-0/+1
When attempting to complete $ git config branch.auto<TAB> 'autosetupmerge' and 'autosetuprebase' don't come up. This is because "$cur" is matched with "branch.*" and a list of branches are completed. Add 'autosetupmerge', 'autosetuprebase' as candidates for completion too, using __gitcomp_nl_append (). Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2014-01-06completion: introduce __gitcomp_nl_append ()Libravatar Ramkumar Ramachandra2-4/+26
There are situations where multiple classes of completions possible. For example branch.<TAB> should try to complete branch.master. branch.autosetupmerge branch.autosetuprebase The first candidate has the suffix ".", and the second/ third candidates have the suffix " ". To facilitate completions of this kind, create a variation of __gitcomp_nl () that appends to the existing list of completion candidates, COMPREPLY. Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2014-01-06zsh completion: find matching custom bash completionLibravatar Ramkumar Ramachandra1-1/+1
If zsh completion is being read from a location that is different from system-wide default, it is likely that the user is trying to use a custom version, perhaps closer to the bleeding edge, installed in her own directory. We will more likely to find the matching bash completion script in the same directory than in those system default places. Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-12-12Merge branch 'jn/scripts-updates'Libravatar Junio C Hamano2-4/+0
* jn/scripts-updates: remove #!interpreter line from shell libraries test: replace shebangs with descriptions in shell libraries test: make FILEMODE a lazy prereq contrib: remove git-p4import mark contributed hooks executable mark perl test scripts executable mark Windows build scripts executable
2013-11-26remove #!interpreter line from shell librariesLibravatar Jonathan Nieder2-4/+0
In a shell snippet meant to be sourced by other shell scripts, an opening #! line does more harm than good. The harm: - When the shell library is sourced, the interpreter and options from the #! line are not used. Specifying a particular shell can confuse the reader into thinking it is safe for the shell library to rely on idiosyncrasies of that shell. - Using #! instead of a plain comment drops a helpful visual clue that this is a shell library and not a self-contained script. - Tools such as lintian can use a #! line to tell when an installation script has failed by forgetting to set a script executable. This check does not work if shell libraries also start with a #! line. The good: - Text editors notice the #! line and use it for syntax highlighting if you try to edit the installed scripts (without ".sh" suffix) in place. The use of the #! for file type detection is not needed because Git's shell libraries are meant to be edited in source form (with ".sh" suffix). Replace the opening #! lines with comments. This involves tweaking the test harness's valgrind support to find shell libraries by looking for "# " in the first line instead of "#!" (see v1.7.6-rc3~7, 2011-06-17). Suggested by Russ Allbery through lintian. Thanks to Jeff King and Clemens Buchacher for further analysis. Tested by searching for non-executable scripts with #! line: find . -name .git -prune -o -type f -not -executable | while read file do read line <"$file" case $line in '#!'*) echo "$file" ;; esac done The only remaining scripts found are templates for shell scripts (unimplemented.sh, wrap-for-bin.sh) and sample input used in tests (t/t4034/perl/{pre,post}). Signed-off-by: Jonathan Nieder <jrnieder@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-11-12peek-remote: remove deprecated alias of ls-remoteLibravatar John Keeping1-1/+0
This has been deprecated since commit 87194d2 (Deprecate peek-remote, 2007-11-24), included in version 1.5.4. Signed-off-by: John Keeping <john@keeping.me.uk> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-11-12lost-found: remove deprecated commandLibravatar John Keeping1-1/+0
"git lost-found" has been deprecated since commit fc8b5f0 (Deprecate git-lost-found, 2007-11-08), included in version 1.5.4. Signed-off-by: John Keeping <john@keeping.me.uk> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-11-12tar-tree: remove deprecated commandLibravatar John Keeping1-1/+0
"git tar-tree" has been a thin wrapper around "git archive" since commit fd88d9c (Remove upload-tar and make git-tar-tree a thin wrapper to git-archive, 2006-09-24), which also made it print a message indicating that git-tar-tree is deprecated. Signed-off-by: John Keeping <john@keeping.me.uk> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-11-12repo-config: remove deprecated alias for "git config"Libravatar John Keeping1-1/+0
The release notes for Git 1.5.4 say that "git repo-config" will be removed in the next feature release. Since Git 2.0 is nearly here, remove it. Signed-off-by: John Keeping <john@keeping.me.uk> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-10-28Merge branch 'sg/prompt-svn-remote-fix'Libravatar Junio C Hamano1-1/+1
Bash portability fix. * sg/prompt-svn-remote-fix: bash prompt: don't use '+=' operator in show upstream code path
2013-10-15bash prompt: don't use '+=' operator in show upstream code pathLibravatar SZEDER Gábor1-1/+1
The '+=' operator is not supported by old Bash versions (3.0) we still care about. Signed-off-by: SZEDER Gábor <szeder@ira.uka.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-10-14git-prompt.sh: optionally show upstream branch nameLibravatar Julien Carsique1-1/+6
When working with multiple remotes, it is common to switch the upstream from a remote to another. Doing so, the prompt may not be the expected one. Providing an option to display tracking information sounds useful. Add a "name" option to GIT_PS1_SHOWUPSTREAM which will show the upstream abbrev name. This option is ignored if "verbose" is false. Signed-off-by: Julien Carsique <julien.carsique@gmail.com> Improved-by: SZEDER Gábor <szeder@ira.uka.de> Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
2013-10-13mergetools/diffmerge: support DiffMerge as a git mergetoolLibravatar Stefan Saasen1-1/+1
DiffMerge is a non-free (but gratis) tool that supports OS X, Windows and Linux. See http://www.sourcegear.com/diffmerge/ DiffMerge includes a script `/usr/bin/diffmerge` that can be used to launch the graphical compare tool. This change adds mergetool support for DiffMerge and adds 'diffmerge' as an option to the mergetool help. Signed-off-by: Stefan Saasen <ssaasen@atlassian.com> Acked-by: David Aguilar <davvid@gmail.com> Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
2013-09-19completion: improve untracked directory filtering for filename completionLibravatar SZEDER Gábor1-2/+2
Similar to Bash's default filename completion, our git-aware filename completion stops at directory boundaries, i.e. it doesn't offer the full 'path/to/file' at first, but only 'path/'. To achieve that the completion script runs 'git ls-files' with specific command line options to get the list of relevant paths under the current directory, and then processes each path to strip all but the base directory or filename (see __git_index_files()). To offer only modified and untracked files for 'git add' the completion script runs 'git ls-files --exclude-standard --others --modified'. This command lists all non-ignored files in untracked directories, which leads to a noticeable delay caused by the processing mentioned above if there are a lot of such files (__git_index_files() specifies '--exclude-standard' internally): $ mkdir untracked-dir $ for i in {1..10000} ; do >untracked-dir/$i ; done $ time __git_index_files "--others --modified" untracked-dir real 0m0.537s user 0m0.452s sys 0m0.160s Eliminate this delay by additionally passing the '--directory --no-empty-directory' options to 'git ls-files' to show only the directory name of non-empty untracked directories instead their whole content: $ time __git_index_files "--others --modified --directory --no-empty-directory" untracked-dir real 0m0.029s user 0m0.020s sys 0m0.004s Filename completion for 'git clean' suffers from the same delay, as it offers untracked files, too. The fix could be the same, but since it actually makes sense to 'git clean' empty directories, in this case we only pass the '--directory' option to 'git ls-files'. Reported-by: Isaac Levy <ilevy@google.com> Signed-off-by: SZEDER Gábor <szeder@ira.uka.de> Reviewed-by: Jonathan Nieder <jrnieder@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-08-22contrib/git-prompt.sh: handle missing 'printf -v' more gracefullyLibravatar Brandon Casey1-1/+5
Old Bash (3.0) which is distributed with RHEL 4.X and other ancient platforms that are still in wide use, do not have a printf that supports -v. Neither does Zsh (which is already handled in the code). As suggested by Junio, let's test whether printf supports the -v option and store the result. Then later, we can use it to determine whether 'printf -v' can be used, or whether printf must be called in a subshell. Signed-off-by: Brandon Casey <drafnel@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-08-21git-completion.bash: use correct Bash/Zsh array length syntaxLibravatar Brandon Casey1-1/+1
The syntax for retrieving the number of elements in an array is: ${#name[@]} Signed-off-by: Brandon Casey <drafnel@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-08-02Merge branch 'rj/cygwin-clarify-use-of-cheating-lstat'Libravatar Junio C Hamano1-1/+0
Cygwin port added a "not quite correct but a lot faster and good enough for many lstat() calls that are only used to see if the working tree entity matches the index entry" lstat() emulation some time ago, and it started biting us in places. This removes it and uses the standard lstat() that comes with Cygwin. Recent topic that uses lstat on packed-refs file is broken when this cheating lstat is used, and this is a simplest fix that is also the cleanest direction to go in the long run. * rj/cygwin-clarify-use-of-cheating-lstat: cygwin: Remove the Win32 l/stat() implementation
2013-07-30Merge branch 'bc/completion-for-bash-3.0'Libravatar Junio C Hamano1-1/+1
* bc/completion-for-bash-3.0: git-completion.bash: replace zsh notation that breaks bash 3.X
2013-07-24git-completion.bash: replace zsh notation that breaks bash 3.XLibravatar Brandon Casey1-1/+1
50c5885e (git-completion.bash: replace zsh notation that breaks bash 3.X, 2013-01-18) fixed a zsh-ism introduced earlier to append to an array, which older versions of bash (3.0) did not grok. This was again broken by 734b2f05 (completion: synchronize zsh wrapper, 2013-05-08). Cherry-pick the fix again to let those with older bash use the completion script. Signed-off-by: Brandon Casey <drafnel@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2013-07-22Merge branch 'es/check-mailmap'Libravatar Junio C Hamano1-0/+1
A new command to allow scripts to query the mailmap information. * es/check-mailmap: t4203: test check-mailmap command invocation builtin: add git-check-mailmap command
2013-07-18cygwin: Remove the Win32 l/stat() implementationLibravatar Ramsay Jones1-1/+0
Commit adbc0b6b ("cygwin: Use native Win32 API for stat", 30-09-2008) added a Win32 specific implementation of the stat functions. In order to handle absolute paths, cygwin mount points and symbolic links, this implementation may fall back on the standard cygwin l/stat() functions. Also, the choice of cygwin or Win32 functions is made lazily (by the first call(s) to l/stat) based on the state of some config variables. Unfortunately, this "schizophrenic stat" implementation has been the source of many problems ever since. For example, see commits 7faee6b8, 79748439, 452993c2, 085479e7, b8a97333, 924aaf3e, 05bab3ea and 0117c2f0. In order to avoid further problems, such as the issue raised by the new reference handling API, remove the Win32 l/stat() implementation. Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk> Signed-off-by: Junio C Hamano <gitster@pobox.com>