From: Jeff King <peff@peff.net>
To: "SZEDER Gábor" <szeder@ira.uka.de>
Cc: git@vger.kernel.org
Subject: Re: [PATCHv2 3/3] completion: match ctags symbol names in grep patterns
Date: Tue, 1 Nov 2011 08:21:48 -0700 [thread overview]
Message-ID: <20111101152148.GA5552@sigill.intra.peff.net> (raw)
In-Reply-To: <20111029124755.GE2345@goldbirke>
On Sat, Oct 29, 2011 at 02:47:55PM +0200, SZEDER Gábor wrote:
> > Grep only looks in the current subdirectory for matches.
>
> Unless the user explicitly specifies the path(s)... But that comes at
> the end of the command line, so the completion script could have no
> idea about it at the time of 'git grep <TAB>'.
True. But that's a more general problem. You have a 'tags' file that
presumably represents the working tree. But you are not necessarily
grepping there. You might be grepping something related (e.g., what's in
the index), which makes the tags file still a good guess.
But you might also be grepping some totally unrelated branch, in which
case this is not helpful.
I tend to think that we are OK erring on the side of using the 'tags'
file, even if it might be wrong, since otherwise we have nothing to
tab-complete. When the user hits <Tab>, they are asking us to make our
best guess, and if they know there is nothing to complete, they won't
hit <Tab>. So it's not like we're hurting some existing workflow.
And in that sense, maybe we should just do the "search back up the
working tree" thing. Sure, it may be return way more matches than are
accurate, but even that's better than having no tab-completion at all.
> > You don't want __gitdir here, but rather "git rev-parse --show-cdup".
>
> Oh, yes, indeed.
>
> But there was a point in using __gitdir() here: it respects the
> --git-dir= option. Which brings up the question: what
> should 'git --git-dir=/some/where/.git grep <TAB>' offer?
I guess if core.worktree is set, it would look there instead (and ditto
for specifying --work-tree on the command line). Handling those is such
a corner case that I'm not too concerned if we don't. And if somebody
really cares, they can fix the completion later to pick up magic like
that from the early part of the command line. I don't see it as a
blocker for an initial version of the patch.
> _get_comp_words_by_ref() is a general completion function, the purpose
> of which is to provide a bash-version-independent equivalent of
> $COMP_WORDS and $COMP_CWORD by working around the different word
> splitting rules. It doesn't know about git and its commands at all.
>
> But there is the while loop in _git() that looks for the git command
> (among other things) on the command line, which could store the index
> of the command name in $words in a variable. This variable could then
> be used in that case statement (and probably in a couple of other
> places, too).
Yeah, that makes sense. Again, my inclination is to just leave that for
a further patch if somebody really wants to make the completion (for
this and any other positional slots) more accurate.
-Peff
next prev parent reply other threads:[~2011-11-01 15:21 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-10-18 4:49 [PATCH 0/3] stupid git tricks Jeff King
2011-10-18 4:52 ` [PATCH 1/3] contrib: add diff highlight script Jeff King
2011-10-18 4:54 ` [PATCH 2/3] contrib: add git-jump script Jeff King
2011-10-18 5:01 ` [PATCH 3/3] completion: match ctags symbol names in grep patterns Jeff King
2011-10-18 7:15 ` Junio C Hamano
2011-10-18 7:26 ` Jonathan Nieder
2011-10-18 7:35 ` Junio C Hamano
2011-10-18 7:41 ` Matthieu Moy
2011-10-18 7:55 ` Junio C Hamano
2011-10-18 7:55 ` Jonathan Nieder
2011-10-18 17:14 ` Junio C Hamano
2011-10-18 15:04 ` Jeff King
2011-10-21 13:25 ` SZEDER Gábor
2011-10-21 17:22 ` Jeff King
2011-10-21 17:26 ` [PATCHv2 1/3] contrib: add diff highlight script Jeff King
2011-10-21 17:28 ` [PATCH 2/3] contrib: add git-jump script Jeff King
2011-10-21 17:35 ` Jeff King
2011-10-21 17:30 ` [PATCHv2 3/3] completion: match ctags symbol names in grep patterns Jeff King
2011-10-21 17:37 ` [PATCHv2 4/3] completion: use __gitcomp_nl for ctag matching Jeff King
2011-10-23 21:29 ` [PATCHv2 3/3] completion: match ctags symbol names in grep patterns SZEDER Gábor
2011-10-28 6:05 ` Jeff King
2011-10-29 12:47 ` SZEDER Gábor
2011-11-01 15:21 ` Jeff King [this message]
2011-11-01 18:14 ` 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=20111101152148.GA5552@sigill.intra.peff.net \
--to=peff@peff.net \
--cc=git@vger.kernel.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.
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).