diff options
author | Peter van der Does <peter@avirtualhome.com> | 2010-12-02 02:17:13 -0600 |
---|---|---|
committer | Jonathan Nieder <jrnieder@gmail.com> | 2010-12-14 23:06:38 -0600 |
commit | da48616f1df51ff43acc64cdf8966f7b72142a11 (patch) | |
tree | dd061049d2cc589c27a00ee1a8741d49d96f86e0 /t/t2201-add-update-typechange.sh | |
parent | Git 1.7.2.4 (diff) | |
download | tgif-da48616f1df51ff43acc64cdf8966f7b72142a11.tar.xz |
bash: get --pretty=m<tab> completion to work with bash v4
Bash's programmable completion provides the COMP_WORDS array variable,
which holds the individual words in the current command line. In bash
versions prior to v4 "words are split on shell metacharacters as the
shell parser would separate them" (quote from bash v3.2.48's man
page). This behavior has changed with bash v4, and the command line
"is split into words as readline would split it, using COMP_WORDBREAKS
as" "the set of characters that the readline library treats as word
separators" (quote from bash v4's man page).
Since COMP_WORDBREAKS contains the characters : and = by default, this
behavior change in bash affects git's completion script. For example,
before bash 4, running
$ git log --pretty=m <tab><tab>
would give a list of pretty-printing formats starting with 'm' but now
it completes on branch names.
It would be possible to work around this by removing '=' and ':' from
COMP_WORDBREAKS, but as noticed in v1.5.6.4~9^2 (bash completion:
Resolve git show ref:path<tab> losing ref: portion, 2008-07-15), that
would break *other* completion scripts. The bash-completion library
includes a better workaround: the _get_comp_words_by_ref function
re-assembles a copy of COMP_WORDS, excluding a collection of word
separators of the caller's choice. Use it.
As a bonus, this also improves behavior when tab is pressed with the
cursor in the middle of a word.
To avoid breaking setups with the bash-completion library not already
loaded, if the _get_comp_words_by_ref function is not defined then a
shim that just reads COMP_WORDS will be used instead (no change from
the current behavior in that case).
Signed-off-by: Peter van der Does <peter@avirtualhome.com>
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Explained-by: SZEDER Gábor <szeder@ira.uka.de>
Diffstat (limited to 't/t2201-add-update-typechange.sh')
0 files changed, 0 insertions, 0 deletions