@@ -413,30 +413,12 @@ __git_reassemble_comp_words_by_ref()
if ! type _get_comp_words_by_ref >/dev/null 2>&1; then
_get_comp_words_by_ref ()
{
- local exclude cur_ words_ cword_
- if [ "$1" = "-n" ]; then
- exclude=$2
- shift 2
- fi
- __git_reassemble_comp_words_by_ref "$exclude"
- cur_=${words_[cword_]}
- while [ $# -gt 0 ]; do
- case "$1" in
- cur)
- cur=$cur_
- ;;
- prev)
- prev=${words_[$cword_-1]}
- ;;
- words)
- words=("${words_[@]}")
- ;;
- cword)
- cword=$cword_
- ;;
- esac
- shift
- done
+ local words_ cword_
+ __git_reassemble_comp_words_by_ref "=:"
+ cword=$cword_
+ cur=${words_[cword]}
+ prev=${words_[cword-1]}
+ words=("${words_[@]}")
}
fi
@@ -40,23 +40,10 @@ GIT_TESTING_PORCELAIN_COMMAND_LIST='add checkout rebase'
# So let's override it with a minimal version for testing purposes.
_get_comp_words_by_ref ()
{
- while [ $# -gt 0 ]; do
- case "$1" in
- cur)
- cur=${_words[_cword]}
- ;;
- prev)
- prev=${_words[_cword-1]}
- ;;
- words)
- words=("${_words[@]}")
- ;;
- cword)
- cword=$_cword
- ;;
- esac
- shift
- done
+ cword=$_cword
+ cur=${_words[cword]}
+ prev=${_words[cword-1]}
+ words=("${_words[@]}")
}
print_comp ()
We don't need the whole functionality of _get_comp_words_by_ref(), we know exactly what we need from that function, so only do that. Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com> --- contrib/completion/git-completion.bash | 30 ++++++-------------------- t/t9902-completion.sh | 21 ++++-------------- 2 files changed, 10 insertions(+), 41 deletions(-)