completion: don't modify the $cur variable in completion functions
commit9244d69b96c209116390804c9af6bb1f5271ae18
authorSZEDER Gábor <szeder@ira.uka.de>
Thu, 28 Apr 2011 16:01:51 +0000 (28 18:01 +0200)
committerJunio C Hamano <gitster@pobox.com>
Thu, 28 Apr 2011 16:40:20 +0000 (28 09:40 -0700)
tree07744f38b27330f65925629ad7e26e873f6587a1
parente839fe6c1206292aeb4518939b8f124ae5068619
completion: don't modify the $cur variable in completion functions

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>
contrib/completion/git-completion.bash