Since v1.7.4-rc0~11^2~2 (bash: get --pretty=m<tab> completion to work
with bash v4, 2010-12-02) we use _get_comp_words_by_ref() to access
completion-related variables, and the $cur variable holds the word
containing the current cursor position in all completion functions.
This $cur variable is left unchanged in most completion functions;
there are only four functions modifying its value, namely __gitcomp(),
__git_complete_revlist_file(), __git_complete_remote_or_refspec(), and
_git_config().
If this variable were never modified, then it would allow us a nice
optimisation and cleanup. Therefore, this patch assigns $cur to an
other local variable and uses that for later modifications in those
four functions.
Signed-off-by: SZEDER Gábor <szeder@ira.uka.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
raw | patch | inline | side by side (parent: e839fe6 )
{
local cur
_get_comp_words_by_ref -n =: cur
{
local cur
_get_comp_words_by_ref -n =: cur
local IFS=$'\n'
COMPREPLY=($(compgen -P "${2-}" \
-W "$(__gitcomp_1 "${1-}" "${4-}")" \
local IFS=$'\n'
COMPREPLY=($(compgen -P "${2-}" \
-W "$(__gitcomp_1 "${1-}" "${4-}")" \
{
local pfx ls ref cur
_get_comp_words_by_ref -n =: cur
{
local pfx ls ref cur
_get_comp_words_by_ref -n =: cur
+ local cur_="$cur"
+ case "$cur_" in
- ref="${cur%%:*}"
- cur="${cur #*:}"
- case "$cur" in
+ ref="${cur_ %%:*}"
+ cur_="${cur_ #*:}"
+ case "$cur_ " in
- pfx="${cur%/*}"
- cur="${cur ##*/}"
+ pfx="${cur_ %/*}"
+ cur_="${cur_ ##*/}"
ls="$ref:$pfx"
pfx="$pfx/"
;;
ls="$ref:$pfx"
pfx="$pfx/"
;;
- pfx="${cur%...*}..."
- cur="${cur #*...}"
- __gitcomp "$(__git_refs)" "$pfx" "$cur"
+ pfx="${cur_ %...*}..."
+ cur_="${cur_ #*...}"
+ __gitcomp "$(__git_refs)" "$pfx" "$cur_ "
- pfx="${cur%..*}.."
- cur="${cur #*..}"
- __gitcomp "$(__git_refs)" "$pfx" "$cur"
+ pfx="${cur_ %..*}.."
+ cur_="${cur_ #*..}"
+ __gitcomp "$(__git_refs)" "$pfx" "$cur_ "
;;
*)
__gitcomp "$(__git_refs)"
;;
*)
__gitcomp "$(__git_refs)"
{
local cur words cword
_get_comp_words_by_ref -n =: cur words cword
{
local cur words cword
_get_comp_words_by_ref -n =: cur words cword
- local cmd="${words[1]}"
+ local cur_="$cur" c md="${words[1]}"
local i c=2 remote="" pfx="" lhs=1 no_complete_refspec=0
while [ $c -lt $cword ]; do
i="${words[c]}"
local i c=2 remote="" pfx="" lhs=1 no_complete_refspec=0
while [ $c -lt $cword ]; do
i="${words[c]}"
return
fi
[ "$remote" = "." ] && remote=
return
fi
[ "$remote" = "." ] && remote=
*:*)
case "$COMP_WORDBREAKS" in
*:*) : great ;;
*:*)
case "$COMP_WORDBREAKS" in
*:*) : great ;;
- *) pfx="${cur%%:*}:" ;;
+ *) pfx="${cur_ %%:*}:" ;;
;;
esac
case "$cmd" in
fetch)
if [ $lhs = 1 ]; then
;;
esac
case "$cmd" in
fetch)
if [ $lhs = 1 ]; then
- __gitcomp "$(__git_refs2 "$remote")" "$pfx" "$cur"
+ __gitcomp "$(__git_refs2 "$remote")" "$pfx" "$cur_ "
- __gitcomp "$(__git_refs)" "$pfx" "$cur"
+ __gitcomp "$(__git_refs)" "$pfx" "$cur_ "
fi
;;
pull)
if [ $lhs = 1 ]; then
fi
;;
pull)
if [ $lhs = 1 ]; then
- __gitcomp "$(__git_refs "$remote")" "$pfx" "$cur"
+ __gitcomp "$(__git_refs "$remote")" "$pfx" "$cur_ "
- __gitcomp "$(__git_refs)" "$pfx" "$cur"
+ __gitcomp "$(__git_refs)" "$pfx" "$cur_ "
fi
;;
push)
if [ $lhs = 1 ]; then
fi
;;
push)
if [ $lhs = 1 ]; then
- __gitcomp "$(__git_refs)" "$pfx" "$cur"
+ __gitcomp "$(__git_refs)" "$pfx" "$cur_ "
- __gitcomp "$(__git_refs "$remote")" "$pfx" "$cur"
+ __gitcomp "$(__git_refs "$remote")" "$pfx" "$cur_ "
- local pfx="${cur%.*}."
- cur="${cur##*.}"
- __gitcomp "remote merge mergeoptions rebase" "$pfx" "$cur"
+ local pfx="${cur%.*}." cur_="${cur##*.}"
+ __gitcomp "remote merge mergeoptions rebase" "$pfx" "$cur_"
- local pfx="${cur%.*}."
- cur="${cur#*.}"
- __gitcomp "$(__git_heads)" "$pfx" "$cur" "."
+ local pfx="${cur%.*}." cur_="${cur#*.}"
+ __gitcomp "$(__git_heads)" "$pfx" "$cur_" "."
- local pfx="${cur%.*}."
- cur="${cur##*.}"
+ local pfx="${cur%.*}." cur_="${cur##*.}"
__gitcomp "
argprompt cmd confirm needsfile noconsole norescan
prompt revprompt revunmerged title
__gitcomp "
argprompt cmd confirm needsfile noconsole norescan
prompt revprompt revunmerged title
- local pfx="${cur%.*}."
- cur="${cur##*.}"
- __gitcomp "cmd path" "$pfx" "$cur"
+ local pfx="${cur%.*}." cur_="${cur##*.}"
+ __gitcomp "cmd path" "$pfx" "$cur_"
- local pfx="${cur%.*}."
- cur="${cur##*.}"
- __gitcomp "cmd path" "$pfx" "$cur"
+ local pfx="${cur%.*}." cur_="${cur##*.}"
+ __gitcomp "cmd path" "$pfx" "$cur_"
- local pfx="${cur%.*}."
- cur="${cur##*.}"
- __gitcomp "cmd path trustExitCode" "$pfx" "$cur"
+ local pfx="${cur%.*}." cur_="${cur##*.}"
+ __gitcomp "cmd path trustExitCode" "$pfx" "$cur_"
- local pfx="${cur%.*}."
- cur="${cur#*.}"
+ local pfx="${cur%.*}." cur_="${cur#*.}"
__git_compute_all_commands
__git_compute_all_commands
- __gitcomp "$__git_all_commands" "$pfx" "$cur"
+ __gitcomp "$__git_all_commands" "$pfx" "$cur_ "
- local pfx="${cur%.*}."
- cur="${cur##*.}"
+ local pfx="${cur%.*}." cur_="${cur##*.}"
__gitcomp "
url proxy fetch push mirror skipDefaultUpdate
receivepack uploadpack tagopt pushurl
__gitcomp "
url proxy fetch push mirror skipDefaultUpdate
receivepack uploadpack tagopt pushurl
- local pfx="${cur%.*}."
- cur="${cur#*.}"
- __gitcomp "$(__git_remotes)" "$pfx" "$cur" "."
+ local pfx="${cur%.*}." cur_="${cur#*.}"
+ __gitcomp "$(__git_remotes)" "$pfx" "$cur_" "."
- local pfx="${cur%.*}."
- cur="${cur##*.}"
- __gitcomp "insteadOf pushInsteadOf" "$pfx" "$cur"
+ local pfx="${cur%.*}." cur_="${cur##*.}"
+ __gitcomp "insteadOf pushInsteadOf" "$pfx" "$cur_"