summaryrefslogtreecommitdiff
path: root/plugins/gitfast/_git
diff options
context:
space:
mode:
authorFelipe Contreras <felipe.contreras@gmail.com>2020-11-19 12:45:19 -0600
committerGitHub <noreply@github.com>2020-11-19 19:45:19 +0100
commite92a4667cbd65e9567dc962b5a482e10f319596a (patch)
treed539a4aa02939dbd36cf81615c9a3770c2139faa /plugins/gitfast/_git
parentce836647e5e8b11246e2ef7069001287dc7cdd2b (diff)
downloadzsh-e92a4667cbd65e9567dc962b5a482e10f319596a.tar.gz
zsh-e92a4667cbd65e9567dc962b5a482e10f319596a.tar.bz2
zsh-e92a4667cbd65e9567dc962b5a482e10f319596a.zip
feat(gitfast): update to git-completion 1.2 (#9458)
Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
Diffstat (limited to 'plugins/gitfast/_git')
-rw-r--r--plugins/gitfast/_git129
1 files changed, 64 insertions, 65 deletions
diff --git a/plugins/gitfast/_git b/plugins/gitfast/_git
index aaea581d5..988f5b1c6 100644
--- a/plugins/gitfast/_git
+++ b/plugins/gitfast/_git
@@ -45,71 +45,49 @@ fi
local old_complete="$functions[complete]"
functions[complete]=:
+COMP_WORDBREAKS=':'
GIT_SOURCING_ZSH_COMPLETION=y . "$script"
functions[complete]="$old_complete"
+__gitcompadd ()
+{
+ compadd -Q -p "${2-}" -S "${3- }" ${@[4,-1]} -- ${=1} && _ret=0
+}
+
__gitcomp ()
{
emulate -L zsh
local cur_="${3-$cur}"
- case "$cur_" in
- --*=)
- ;;
- --no-*)
- local c IFS=$' \t\n'
- local -a array
- for c in ${=1}; do
- if [[ $c == "--" ]]; then
- continue
- fi
- c="$c${4-}"
- case $c in
- --*=|*.) ;;
- *) c="$c " ;;
- esac
- array+=("$c")
- done
- compset -P '*[=:]'
- compadd -Q -S '' -p "${2-}" -a -- array && _ret=0
- ;;
- *)
- local c IFS=$' \t\n'
- local -a array
- for c in ${=1}; do
- if [[ $c == "--" ]]; then
- c="--no-...${4-}"
- array+=("$c ")
- break
- fi
- c="$c${4-}"
- case $c in
- --*=|*.) ;;
- *) c="$c " ;;
- esac
- array+=("$c")
- done
- compset -P '*[=:]'
- compadd -Q -S '' -p "${2-}" -a -- array && _ret=0
- ;;
- esac
-}
+ [[ "$cur_" == *= ]] && return
-__gitcomp_direct ()
-{
- emulate -L zsh
+ local c IFS=$' \t\n' sfx
+ for c in ${=1}; do
+ if [[ $c == "--" ]]; then
+ [[ "$cur_" == --no-* ]] && continue
+ __gitcompadd "--no-..."
+ break
+ fi
- compset -P '*[=:]'
- compadd -Q -S '' -- ${(f)1} && _ret=0
+ if [[ -z "${4-}" ]]; then
+ case $c in
+ *=) c="${c%=}"; sfx="=" ;;
+ *.) sfx="" ;;
+ *) sfx=" " ;;
+ esac
+ else
+ sfx="$4"
+ fi
+ __gitcompadd "$c" "${2-}" "$sfx" -q
+ done
}
__gitcomp_nl ()
{
emulate -L zsh
- compset -P '*[=:]'
- compadd -Q -S "${4- }" -p "${2-}" -- ${(f)1} && _ret=0
+ IFS=$'\n' __gitcompadd "$1" "${2-}" "${4- }"
}
__gitcomp_file ()
@@ -119,9 +97,14 @@ __gitcomp_file ()
compadd -f -p "${2-}" -- ${(f)1} && _ret=0
}
-__gitcomp_direct_append ()
+__gitcomp_direct ()
{
- __gitcomp_direct "$@"
+ __gitcomp_nl "$1" "" "" ""
+}
+
+__gitcomp_file_direct ()
+{
+ __gitcomp_file "$1" ""
}
__gitcomp_nl_append ()
@@ -129,25 +112,30 @@ __gitcomp_nl_append ()
__gitcomp_nl "$@"
}
-__gitcomp_file_direct ()
+__gitcomp_direct_append ()
{
- __gitcomp_file "$1" ""
+ __gitcomp_direct "$@"
}
_git_zsh ()
{
- __gitcomp "v1.0"
+ __gitcomp "v1.2"
}
__git_complete_command ()
{
emulate -L zsh
+ compset -P '*[=:]'
+
local command="$1"
local completion_func="_git_${command//-/_}"
if (( $+functions[$completion_func] )); then
emulate ksh -c $completion_func
return 0
+ elif emulate ksh -c "__git_support_parseopt_helper $command"; then
+ emulate ksh -c "__git_complete_common $command"
+ return 0
else
return 1
fi
@@ -218,24 +206,27 @@ __git_zsh_main ()
{
local curcontext="$curcontext" state state_descr line
typeset -A opt_args
- local -a orig_words
+ local -a orig_words __git_C_args
orig_words=( ${words[@]} )
_arguments -C \
- '(-p --paginate --no-pager)'{-p,--paginate}'[pipe all output into ''less'']' \
- '(-p --paginate)--no-pager[do not pipe git output into a pager]' \
- '--git-dir=-[set the path to the repository]: :_directories' \
- '--bare[treat the repository as a bare repository]' \
+ '(-p --paginate -P --no-pager)'{-p,--paginate}'[pipe all output into ''less'']' \
+ '(-p --paginate -P --no-pager)'{-P,--no-pager}'[do not pipe git output into a pager]' \
+ '(--bare)--git-dir=[set the path to the repository]: :_directories' \
+ '(--git-dir)--bare[treat the repository as a bare repository]' \
'(- :)--version[prints the git suite version]' \
- '--exec-path=-[path to where your core git programs are installed]:: :_directories' \
- '--html-path[print the path where git''s HTML documentation is installed]' \
- '--info-path[print the path where the Info files are installed]' \
- '--man-path[print the manpath (see `man(1)`) for the man pages]' \
- '--work-tree=-[set the path to the working tree]: :_directories' \
- '--namespace=-[set the git namespace]' \
+ '--exec-path=[path to where your core git programs are installed]: :_directories' \
+ '(- :)--exec-path[print the path where your core git programs are installed]' \
+ '(- :)--html-path[print the path where git''s HTML documentation is installed]' \
+ '(- :)--info-path[print the path where the Info files are installed]' \
+ '(- :)--man-path[print the manpath (see `man(1)`) for the man pages]' \
+ '--work-tree=[set the path to the working tree]: :_directories' \
+ '--namespace=[set the git namespace]:' \
'--no-replace-objects[do not use replacement refs to replace git objects]' \
'(- :)--help[prints the synopsis and a list of the most commonly used commands]: :->arg' \
+ '*-C[run as if git was started in the given path]: :_directories' \
+ '*-c[pass a configuration parameter to the command]: :->config' \
'(-): :->command' \
'(-)*:: :->arg' && return
@@ -249,15 +240,23 @@ __git_zsh_main ()
let _ret || break
done
;;
+ (config)
+ compset -P '*[=:]'
+ emulate ksh -c __git_complete_config_variable_name_and_value
+ ;;
(arg)
local command="${words[1]}" __git_dir
if (( $+opt_args[--bare] )); then
__git_dir='.'
else
- __git_dir=${opt_args[--git-dir]}
+ __git_dir=${~opt_args[--git-dir]}
fi
+ for x in ${(s.:.)opt_args[-C]}; do
+ __git_C_args+=('-C' ${~x})
+ done
+
(( $+opt_args[--help] )) && command='help'
words=( ${orig_words[@]} )