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:
commit
30159e530d
@ -178,9 +178,9 @@ _get_comp_words_by_ref ()
|
|||||||
}
|
}
|
||||||
fi
|
fi
|
||||||
|
|
||||||
__gitcompadd ()
|
__gitcompappend ()
|
||||||
{
|
{
|
||||||
local i=0
|
local i=${#COMPREPLY[@]}
|
||||||
for x in $1; do
|
for x in $1; do
|
||||||
if [[ "$x" == "$3"* ]]; then
|
if [[ "$x" == "$3"* ]]; then
|
||||||
COMPREPLY[i++]="$2$x$4"
|
COMPREPLY[i++]="$2$x$4"
|
||||||
@ -188,6 +188,12 @@ __gitcompadd ()
|
|||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
|
__gitcompadd ()
|
||||||
|
{
|
||||||
|
COMPREPLY=()
|
||||||
|
__gitcompappend "$@"
|
||||||
|
}
|
||||||
|
|
||||||
# Generates completion reply, appending a space to possible completion words,
|
# Generates completion reply, appending a space to possible completion words,
|
||||||
# if necessary.
|
# if necessary.
|
||||||
# It accepts 1 to 4 arguments:
|
# It accepts 1 to 4 arguments:
|
||||||
@ -218,6 +224,14 @@ __gitcomp ()
|
|||||||
esac
|
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
|
# Generates completion reply from newline-separated possible completion words
|
||||||
# by appending a space to all of them.
|
# by appending a space to all of them.
|
||||||
# It accepts 1 to 4 arguments:
|
# It accepts 1 to 4 arguments:
|
||||||
@ -229,8 +243,8 @@ __gitcomp ()
|
|||||||
# appended.
|
# appended.
|
||||||
__gitcomp_nl ()
|
__gitcomp_nl ()
|
||||||
{
|
{
|
||||||
local IFS=$'\n'
|
COMPREPLY=()
|
||||||
__gitcompadd "$1" "${2-}" "${3-$cur}" "${4- }"
|
__gitcomp_nl_append "$@"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Generates completion reply with compgen from newline-separated possible
|
# Generates completion reply with compgen from newline-separated possible
|
||||||
@ -1827,6 +1841,7 @@ _git_config ()
|
|||||||
branch.*)
|
branch.*)
|
||||||
local pfx="${cur%.*}." cur_="${cur#*.}"
|
local pfx="${cur%.*}." cur_="${cur#*.}"
|
||||||
__gitcomp_nl "$(__git_heads)" "$pfx" "$cur_" "."
|
__gitcomp_nl "$(__git_heads)" "$pfx" "$cur_" "."
|
||||||
|
__gitcomp_nl_append $'autosetupmerge\nautosetuprebase\n' "$pfx" "$cur_"
|
||||||
return
|
return
|
||||||
;;
|
;;
|
||||||
guitool.*.*)
|
guitool.*.*)
|
||||||
@ -1869,6 +1884,7 @@ _git_config ()
|
|||||||
remote.*)
|
remote.*)
|
||||||
local pfx="${cur%.*}." cur_="${cur#*.}"
|
local pfx="${cur%.*}." cur_="${cur#*.}"
|
||||||
__gitcomp_nl "$(__git_remotes)" "$pfx" "$cur_" "."
|
__gitcomp_nl "$(__git_remotes)" "$pfx" "$cur_" "."
|
||||||
|
__gitcomp_nl_append "pushdefault" "$pfx" "$cur_"
|
||||||
return
|
return
|
||||||
;;
|
;;
|
||||||
url.*.*)
|
url.*.*)
|
||||||
|
@ -30,10 +30,10 @@ if [ -z "$script" ]; then
|
|||||||
local -a locations
|
local -a locations
|
||||||
local e
|
local e
|
||||||
locations=(
|
locations=(
|
||||||
|
$(dirname ${funcsourcetrace[1]%:*})/git-completion.bash
|
||||||
'/etc/bash_completion.d/git' # fedora, old debian
|
'/etc/bash_completion.d/git' # fedora, old debian
|
||||||
'/usr/share/bash-completion/completions/git' # arch, ubuntu, new debian
|
'/usr/share/bash-completion/completions/git' # arch, ubuntu, new debian
|
||||||
'/usr/share/bash-completion/git' # gentoo
|
'/usr/share/bash-completion/git' # gentoo
|
||||||
$(dirname ${funcsourcetrace[1]%:*})/git-completion.bash
|
|
||||||
)
|
)
|
||||||
for e in $locations; do
|
for e in $locations; do
|
||||||
test -f $e && script="$e" && break
|
test -f $e && script="$e" && break
|
||||||
@ -76,6 +76,14 @@ __gitcomp_nl ()
|
|||||||
compadd -Q -S "${4- }" -p "${2-}" -- ${=1} && _ret=0
|
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 ()
|
__gitcomp_file ()
|
||||||
{
|
{
|
||||||
emulate -L zsh
|
emulate -L zsh
|
||||||
|
Loading…
Reference in New Issue
Block a user