From: Thomas Rast <trast@student.ethz.ch>
To: "Shawn O. Pearce" <spearce@spearce.org>
Cc: <git@vger.kernel.org>
Subject: Re: [RFC PATCH] bash completion: complete refs for git-grep
Date: Wed, 7 Oct 2009 17:27:49 +0200 [thread overview]
Message-ID: <200910071727.50770.trast@student.ethz.ch> (raw)
In-Reply-To: <20091006154555.GN9261@spearce.org>
Shawn O. Pearce wrote:
>
> Thomas Rast <trast@student.ethz.ch> wrote:
> > + local i c=1 have_regex=""
> > + while [ $c -lt $COMP_CWORD ]; do
> > + i="${COMP_WORDS[c]}"
> > + case "$i" in
> > + -e) ;;
> > + -e*) have_regex="$c" ; break ;;
> > + -*) ;;
> > + *) have_regex="$c"; break ;;
> > + esac
> > + c=$((++c))
> > + done
>
> What happens with `git grep -e a -e b`? Do we trigger into ref
> completion too early when we should still be doing the regex
> completion?
Hmm, true, I would also have to check for the last argument (before
completion) being -e.
However, that is kind of moot because we currently complete filenames
anyway, and you said I can't stop that:
> > This is still RFC because, as you can see in the code below, I tried
> > to avoid completing at all while the user still needs to supply a
> > regex. Sadly, bash turns the COMPREPLY=() into filename completion
> > anyway. Is there a way to prevent this?
>
> Not that I know of. You can turn off default filename completion
> when you register the completion function, but that then breaks
> like every other git command for completion support because a lot
> of them do want to complete filenames.
So I'll roll a simpler patch that just always (before --) completes
refs instead, if that's ok.
--
Thomas Rast
trast@{inf,student}.ethz.ch
next prev parent reply other threads:[~2009-10-07 15:35 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-10-06 10:08 [RFC PATCH] bash completion: complete refs for git-grep Thomas Rast
2009-10-06 15:45 ` Shawn O. Pearce
2009-10-07 15:27 ` Thomas Rast [this message]
2009-10-12 9:00 ` [PATCH] " Thomas Rast
2009-10-12 14:27 ` Shawn O. Pearce
2009-10-12 23:42 ` Junio C Hamano
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=200910071727.50770.trast@student.ethz.ch \
--to=trast@student.ethz.ch \
--cc=git@vger.kernel.org \
--cc=spearce@spearce.org \
/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.
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 NNTP newsgroup(s).