public inbox for git@vger.kernel.org 
 help / color / mirror / Atom feed
From: "Shawn O. Pearce" <spearce@spearce•org>
To: Lee Marlow <lee.marlow@gmail•com>
Cc: git@vger•kernel.org
Subject: Re: [PATCH] bash completion: Add completion for 'git grep'
Date: Sun, 3 Aug 2008 21:06:34 -0700	[thread overview]
Message-ID: <20080804040634.GC2963@spearce.org> (raw)
In-Reply-To: <7968d7490808030031v39726af6r9f88feb28df02de7@mail.gmail.com>

Lee Marlow <lee.marlow@gmail•com> wrote:
> On Sat, Aug 2, 2008 at 3:05 PM, Shawn O. Pearce <spearce@spearce•org> wrote:
> >
> > Hmm.  The has_doubledash test seems redundant since we don't do
> > anything with args that aren't --foo.  Even though git-grep will
> > accept a tree-ish and thus completion of __git_refs here may
> 
> I haven't found myself using grep to search anything but the current
> working directory.  I wonder whether __git_complete_file would be
> better than __git_refs.  My issue with __git_complete_file in this
> case and also doing completion for 'git mv' is that it falls back to
> just __git_refs.  Would it be better if it fell back to __git_refs and
> ls-tree for HEAD?  That way when using completion to get to
> Documentation/git-grep.txt,  it doesn't also show completions for
> Documentation/git-grep.{1,html,xml}.

Hmm.  __git_complete_file is about completing something in a tree-ish,
which is really most likely not what we want for grep.  Its useful for
git-show and git-cat-file, and that's about it.  Most git tools prefer
a calling format of "tree-ish -- paths ..." and not "tree-ish:path".

Though I think you have an excellent point about completing paths
by ls-tree for HEAD rather than the working directory itself,
as then you can avoid produced files.  But in practice how often
do you pass a single file or a couple of files to the grep utility
and are having problems bypassing the build products?  Compared to
just running grep on the entire source tree to find hits?  I never
use grep to search in a single file, but I call it several times
a day to look for where a function is defined or called.

After having thought about it your original patch makes the most
sense, but without the has_doubledash test.

-- 
Shawn.

  reply	other threads:[~2008-08-04  4:07 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-08-02  0:56 [PATCH] bash completion: Add completion for 'git grep' Lee Marlow
2008-08-02 21:05 ` Shawn O. Pearce
2008-08-03  7:31   ` Lee Marlow
2008-08-04  4:06     ` Shawn O. Pearce [this message]
2008-08-04  5:26       ` Lee Marlow
2008-08-04 14:52         ` Shawn O. Pearce
2008-08-04 14:53 ` Shawn O. Pearce

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=20080804040634.GC2963@spearce.org \
    --to=spearce@spearce$(echo .)org \
    --cc=git@vger$(echo .)kernel.org \
    --cc=lee.marlow@gmail$(echo .)com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
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