]> git.ipfire.org Git - thirdparty/git.git/commit - contrib/completion/git-completion.bash
completion: remove unnecessary _get_comp_words_by_ref() invocations
authorSZEDER Gábor <szeder@ira.uka.de>
Thu, 28 Apr 2011 16:01:52 +0000 (18:01 +0200)
committerJunio C Hamano <gitster@pobox.com>
Thu, 28 Apr 2011 16:40:20 +0000 (09:40 -0700)
commitda4902a73017ad82b9926d03101ec69a2802d1e7
tree0d01fa59241bc585bbe73bad87cae1cbe4048e5c
parent9244d69b96c209116390804c9af6bb1f5271ae18
completion: remove unnecessary _get_comp_words_by_ref() invocations

In v1.7.4-rc0~11^2~2 (bash: get --pretty=m<tab> completion to work
with bash v4, 2010-12-02) we started to use _get_comp_words_by_ref()
to access completion-related variables.  That was large change, and to
make it easily reviewable, we invoked _get_comp_words_by_ref() in each
completion function and systematically replaced every occurance of
bash's completion-related variables ($COMP_WORDS and $COMP_CWORD) with
variables set by _get_comp_words_by_ref().

This has the downside that _get_comp_words_by_ref() is invoked several
times during a single completion.  The worst offender is perhaps 'git
log mas<TAB>': during the completion of 'master'
_get_comp_words_by_ref() is invoked no less than six times.

However, the variables $prev, $cword, and $words provided by
_get_comp_words_by_ref() are not modified in any of the completion
functions, and the previous commit ensures that the $cur variable is
not modified as well.  This makes it possible to invoke
_get_comp_words_by_ref() to get those variables only once in our
toplevel completion functions _git() and _gitk(), and all other
completion functions will inherit them.

Signed-off-by: SZEDER Gábor <szeder@ira.uka.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
contrib/completion/git-completion.bash