зеркало из https://github.com/microsoft/git.git
Merge branch 'rr/completion-branch-config'
Two-level configuration variable names in "branch.*" and "remote.*" hierarchies whose variables are predominantly three-level where not completed by hitting a <TAB> in bash and zsh completions. * rr/completion-branch-config: completion: fix remote.pushdefault completion: fix branch.autosetup(merge|rebase) completion: introduce __gitcomp_nl_append () zsh completion: find matching custom bash completion
This commit is contained in:
Коммит
30159e530d
|
@ -178,9 +178,9 @@ _get_comp_words_by_ref ()
|
|||
}
|
||||
fi
|
||||
|
||||
__gitcompadd ()
|
||||
__gitcompappend ()
|
||||
{
|
||||
local i=0
|
||||
local i=${#COMPREPLY[@]}
|
||||
for x in $1; do
|
||||
if [[ "$x" == "$3"* ]]; then
|
||||
COMPREPLY[i++]="$2$x$4"
|
||||
|
@ -188,6 +188,12 @@ __gitcompadd ()
|
|||
done
|
||||
}
|
||||
|
||||
__gitcompadd ()
|
||||
{
|
||||
COMPREPLY=()
|
||||
__gitcompappend "$@"
|
||||
}
|
||||
|
||||
# Generates completion reply, appending a space to possible completion words,
|
||||
# if necessary.
|
||||
# It accepts 1 to 4 arguments:
|
||||
|
@ -218,6 +224,14 @@ __gitcomp ()
|
|||
esac
|
||||
}
|
||||
|
||||
# Variation of __gitcomp_nl () that appends to the existing list of
|
||||
# completion candidates, COMPREPLY.
|
||||
__gitcomp_nl_append ()
|
||||
{
|
||||
local IFS=$'\n'
|
||||
__gitcompappend "$1" "${2-}" "${3-$cur}" "${4- }"
|
||||
}
|
||||
|
||||
# Generates completion reply from newline-separated possible completion words
|
||||
# by appending a space to all of them.
|
||||
# It accepts 1 to 4 arguments:
|
||||
|
@ -229,8 +243,8 @@ __gitcomp ()
|
|||
# appended.
|
||||
__gitcomp_nl ()
|
||||
{
|
||||
local IFS=$'\n'
|
||||
__gitcompadd "$1" "${2-}" "${3-$cur}" "${4- }"
|
||||
COMPREPLY=()
|
||||
__gitcomp_nl_append "$@"
|
||||
}
|
||||
|
||||
# Generates completion reply with compgen from newline-separated possible
|
||||
|
@ -1827,6 +1841,7 @@ _git_config ()
|
|||
branch.*)
|
||||
local pfx="${cur%.*}." cur_="${cur#*.}"
|
||||
__gitcomp_nl "$(__git_heads)" "$pfx" "$cur_" "."
|
||||
__gitcomp_nl_append $'autosetupmerge\nautosetuprebase\n' "$pfx" "$cur_"
|
||||
return
|
||||
;;
|
||||
guitool.*.*)
|
||||
|
@ -1869,6 +1884,7 @@ _git_config ()
|
|||
remote.*)
|
||||
local pfx="${cur%.*}." cur_="${cur#*.}"
|
||||
__gitcomp_nl "$(__git_remotes)" "$pfx" "$cur_" "."
|
||||
__gitcomp_nl_append "pushdefault" "$pfx" "$cur_"
|
||||
return
|
||||
;;
|
||||
url.*.*)
|
||||
|
|
|
@ -30,10 +30,10 @@ if [ -z "$script" ]; then
|
|||
local -a locations
|
||||
local e
|
||||
locations=(
|
||||
$(dirname ${funcsourcetrace[1]%:*})/git-completion.bash
|
||||
'/etc/bash_completion.d/git' # fedora, old debian
|
||||
'/usr/share/bash-completion/completions/git' # arch, ubuntu, new debian
|
||||
'/usr/share/bash-completion/git' # gentoo
|
||||
$(dirname ${funcsourcetrace[1]%:*})/git-completion.bash
|
||||
)
|
||||
for e in $locations; do
|
||||
test -f $e && script="$e" && break
|
||||
|
@ -76,6 +76,14 @@ __gitcomp_nl ()
|
|||
compadd -Q -S "${4- }" -p "${2-}" -- ${=1} && _ret=0
|
||||
}
|
||||
|
||||
__gitcomp_nl_append ()
|
||||
{
|
||||
emulate -L zsh
|
||||
|
||||
local IFS=$'\n'
|
||||
compadd -Q -S "${4- }" -p "${2-}" -- ${=1} && _ret=0
|
||||
}
|
||||
|
||||
__gitcomp_file ()
|
||||
{
|
||||
emulate -L zsh
|
||||
|
|
Загрузка…
Ссылка в новой задаче