From: Jonathan Nieder <jrnieder@gmail.com>
To: Peter van der Does <peter@avirtualhome.com>
Cc: "Shawn O. Pearce" <spearce@spearce.org>,
git@vger.kernel.org, "SZEDER Gábor" <szeder@ira.uka.de>
Subject: Re: [PATCH v4 2/2] Use the new functions to get the current cword.
Date: Thu, 2 Dec 2010 01:45:04 -0600 [thread overview]
Message-ID: <20101202074504.GA1771@burratino> (raw)
In-Reply-To: <1291236582-28603-3-git-send-email-peter@avirtualhome.com>
Hi Peter,
Peter van der Does wrote:
> Change the completion functions to use the newly introduced functions to
> get the current and/or previous cword and to reassemble the COMP_CWORDS,
> making sure the options are correctly split.
Some comments. Please don't reroll until discussion has quieted down
(though thoughts and incremental patches would always be welcome, of
course).
> --- a/contrib/completion/git-completion.bash
> +++ b/contrib/completion/git-completion.bash
> @@ -554,7 +554,8 @@ __gitcomp_1 ()
> # generates completion reply with compgen
> __gitcomp ()
> {
> - local cur="${COMP_WORDS[COMP_CWORD]}"
> + local cur
> + _get_comp_words_by_ref -n "=" cur
To save the reader some time: this excludes '=' from word-breaking
characters, so $cur will include an = when appropriate. IIUC that is
precisely the behavior that bash 4 changed.
Perhaps that is worth explaining in the commit message in the next
round?
> @@ -615,7 +616,8 @@ __git_tags ()
> __git_refs ()
> {
> local i is_hash=y dir="$(__gitdir "${1-}")" track="${2-}"
> - local cur="${COMP_WORDS[COMP_CWORD]}" format refs
> + local cur format refs
> + _get_comp_words_by_ref cur
This does not exclude '=' from word-breaking characters. Would that
break completion of
git update-ref refs/topics/foo=bar HEAD
git checkout refs/topics/foo=<tab><tab>
?
> @@ -729,7 +731,8 @@ __git_compute_merge_strategies ()
>
> __git_complete_file ()
> {
> - local pfx ls ref cur="${COMP_WORDS[COMP_CWORD]}"
> + local pfx ls ref cur
> + _get_comp_words_by_ref -n ":" cur
This treats '=' as a word-breaking character but not ':'. Is that
the right behavior?
> @@ -777,7 +780,8 @@ __git_complete_file ()
>
> __git_complete_revlist ()
> {
> - local pfx cur="${COMP_WORDS[COMP_CWORD]}"
> + local pfx cur
> + _get_comp_words_by_ref cur
'=' and ':' are word-breakers.
> @@ -797,11 +801,13 @@ __git_complete_revlist ()
>
> __git_complete_remote_or_refspec ()
> {
> - local cmd="${COMP_WORDS[1]}"
> - local cur="${COMP_WORDS[COMP_CWORD]}"
> + local cur words cword
> + _get_comp_words_by_ref -n ":" cur words cword
> + local cmd="${words[1]}"
'=' is a word-breaker, ':' not.
> @@ -869,13 +875,15 @@ __git_complete_remote_or_refspec ()
>
> __git_complete_strategy ()
> {
> + local cur prev
> + _get_comp_words_by_ref -n "=" cur prev
'=' is not a wordbreaker, so --strategy= can be completed correctly.
> @@ -1048,10 +1056,11 @@ __git_aliased_command ()
> # __git_find_on_cmdline requires 1 argument
> __git_find_on_cmdline ()
> {
> - local word subcommand c=1
> + local word subcommand c=1 words cword
>
> - while [ $c -lt $COMP_CWORD ]; do
> - word="${COMP_WORDS[c]}"
> + _get_comp_words_by_ref words cword
':' and '=' are word-breakers when completing subcommand names.
> @@ -1064,9 +1073,10 @@ __git_find_on_cmdline ()
>
> __git_has_doubledash ()
> {
> - local c=1
> - while [ $c -lt $COMP_CWORD ]; do
> - if [ "--" = "${COMP_WORDS[c]}" ]; then
> + local c=1, words cword
Extra comma.
> + _get_comp_words_by_ref words cword
':' and '=' are word-breakers when looking for "--".
[etc]
So in general, it seems that : and = are treated as word-breakers
after this change much more often than git itself would treat them
as such. Is that intentional? What rule is used to choose -n
arguments?
next prev parent reply other threads:[~2010-12-02 7:45 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-12-01 20:49 [PATCH v4 0/2] *** SUBJECT HERE *** Peter van der Does
2010-12-01 20:49 ` [PATCH v4 1/2] Introduce functions from bash-completion project Peter van der Does
2010-12-01 20:49 ` [PATCH v4 2/2] Use the new functions to get the current cword Peter van der Does
2010-12-02 7:45 ` Jonathan Nieder [this message]
2010-12-02 22:36 ` SZEDER Gábor
2010-12-01 21:09 ` [PATCH v4 0/2] Make git-completion Bash 4 compatible Jonathan Nieder
2010-12-02 1:10 ` SZEDER Gábor
2010-12-02 9:16 ` Jonathan Nieder
2010-12-02 14:16 ` Peter van der Does
2010-12-02 21:02 ` [RFC/PATCH 2/1] bash: eliminate dependency on bash_completion lib Jonathan Nieder
2010-12-02 23:40 ` SZEDER Gábor
2010-12-03 0:07 ` Jonathan Nieder
2010-12-03 8:02 ` Stephen Boyd
2010-12-07 16:07 ` SZEDER Gábor
2010-12-07 19:49 ` Jonathan Nieder
2010-12-07 20:41 ` SZEDER Gábor
2010-12-07 20:59 ` Jonathan Nieder
2010-12-07 21:03 ` Junio C Hamano
2010-12-15 6:24 ` [PATCH v5.1 0/3] Make git-completion Bash 4 compatible Jonathan Nieder
2010-12-15 6:26 ` [PATCH 1/3] bash: get --pretty=m<tab> completion to work with bash v4 Jonathan Nieder
2010-12-15 6:27 ` [PATCH 2/3] bash: simple reimplementation of _get_comp_words_by_ref Jonathan Nieder
2010-12-15 6:42 ` [MERGE PATCH 3/3] Merge branch 'master' (early part) into pd/bash-4-completion Jonathan Nieder
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20101202074504.GA1771@burratino \
--to=jrnieder@gmail.com \
--cc=git@vger.kernel.org \
--cc=peter@avirtualhome.com \
--cc=spearce@spearce.org \
--cc=szeder@ira.uka.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).