|
@@ -33,8 +33,9 @@ if [ -z "$script" ]; then
|
|
|
bash_completion='/usr/share/bash-completion/completions/'
|
|
|
|
|
|
locations=(
|
|
|
- "$(dirname ${funcsourcetrace[1]%:*})"/git-completion.bash
|
|
|
+ "${${funcsourcetrace[1]%:*}:A:h}"/git-completion.bash
|
|
|
"$HOME/.local/share/bash-completion/completions/git"
|
|
|
+ '/usr/local/share/bash-completion/completions/git'
|
|
|
"$bash_completion/git"
|
|
|
'/etc/bash_completion.d/git' # old debian
|
|
|
)
|
|
@@ -51,13 +52,20 @@ functions[complete]="$old_complete"
|
|
|
|
|
|
__gitcompadd ()
|
|
|
{
|
|
|
- compadd -Q -p "${2-}" -S "${3- }" ${@[4,-1]} -- ${=1} && _ret=0
|
|
|
+ compadd -p "${2-}" -S "${3- }" -q -- ${=1} && _ret=0
|
|
|
}
|
|
|
|
|
|
__gitcomp ()
|
|
|
{
|
|
|
emulate -L zsh
|
|
|
|
|
|
+ IFS=$' \t\n' __gitcompadd "$1" "${2-}" "${4- }"
|
|
|
+}
|
|
|
+
|
|
|
+__gitcomp_opts ()
|
|
|
+{
|
|
|
+ emulate -L zsh
|
|
|
+
|
|
|
local cur_="${3-$cur}"
|
|
|
|
|
|
[[ "$cur_" == *= ]] && return
|
|
@@ -70,7 +78,7 @@ __gitcomp ()
|
|
|
break
|
|
|
fi
|
|
|
|
|
|
- if [[ -z "${4-}" ]]; then
|
|
|
+ if [[ -z "${4+set}" ]]; then
|
|
|
case $c in
|
|
|
*=) c="${c%=}"; sfx="=" ;;
|
|
|
*.) sfx="" ;;
|
|
@@ -79,7 +87,7 @@ __gitcomp ()
|
|
|
else
|
|
|
sfx="$4"
|
|
|
fi
|
|
|
- __gitcompadd "$c" "${2-}" "$sfx" -q
|
|
|
+ __gitcompadd "$c" "${2-}" "$sfx"
|
|
|
done
|
|
|
}
|
|
|
|
|
@@ -87,7 +95,10 @@ __gitcomp_nl ()
|
|
|
{
|
|
|
emulate -L zsh
|
|
|
|
|
|
- IFS=$'\n' __gitcompadd "$1" "${2-}" "${4- }"
|
|
|
+ # words that don't end up in space
|
|
|
+ compadd -p "${2-}" -S "${4- }" -q -- ${${(f)1}:#*\ } && _ret=0
|
|
|
+ # words that end in space
|
|
|
+ compadd -p "${2-}" -S " ${4- }" -q -- ${${(M)${(f)1}:#*\ }% } && _ret=0
|
|
|
}
|
|
|
|
|
|
__gitcomp_file ()
|
|
@@ -107,21 +118,6 @@ __gitcomp_file_direct ()
|
|
|
__gitcomp_file "$1" ""
|
|
|
}
|
|
|
|
|
|
-__gitcomp_nl_append ()
|
|
|
-{
|
|
|
- __gitcomp_nl "$@"
|
|
|
-}
|
|
|
-
|
|
|
-__gitcomp_direct_append ()
|
|
|
-{
|
|
|
- __gitcomp_direct "$@"
|
|
|
-}
|
|
|
-
|
|
|
-_git_zsh ()
|
|
|
-{
|
|
|
- __gitcomp "v1.2"
|
|
|
-}
|
|
|
-
|
|
|
__git_complete_command ()
|
|
|
{
|
|
|
emulate -L zsh
|
|
@@ -206,9 +202,7 @@ __git_zsh_main ()
|
|
|
{
|
|
|
local curcontext="$curcontext" state state_descr line
|
|
|
typeset -A opt_args
|
|
|
- local -a orig_words __git_C_args
|
|
|
-
|
|
|
- orig_words=( ${words[@]} )
|
|
|
+ local -a __git_C_args
|
|
|
|
|
|
_arguments -C \
|
|
|
'(-p --paginate -P --no-pager)'{-p,--paginate}'[pipe all output into ''less'']' \
|
|
@@ -245,7 +239,7 @@ __git_zsh_main ()
|
|
|
emulate ksh -c __git_complete_config_variable_name_and_value
|
|
|
;;
|
|
|
(arg)
|
|
|
- local command="${words[1]}" __git_dir
|
|
|
+ local command="${words[1]}" __git_dir __git_cmd_idx=1
|
|
|
|
|
|
if (( $+opt_args[--bare] )); then
|
|
|
__git_dir='.'
|
|
@@ -259,7 +253,7 @@ __git_zsh_main ()
|
|
|
|
|
|
(( $+opt_args[--help] )) && command='help'
|
|
|
|
|
|
- words=( ${orig_words[@]} )
|
|
|
+ words=( git ${words[@]} )
|
|
|
|
|
|
__git_zsh_bash_func $command
|
|
|
;;
|
|
@@ -269,7 +263,7 @@ __git_zsh_main ()
|
|
|
_git ()
|
|
|
{
|
|
|
local _ret=1
|
|
|
- local cur cword prev
|
|
|
+ local cur cword prev __git_cmd_idx=0
|
|
|
|
|
|
cur=${words[CURRENT]}
|
|
|
prev=${words[CURRENT-1]}
|