git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jeff King <peff@peff.net>
To: Josh Hagins <hagins.josh@gmail.com>
Cc: Thiago Farina <tfransosi@gmail.com>,
	Git Mailing List <git@vger.kernel.org>
Subject: Re: multiple source file extensions
Date: Fri, 1 May 2015 21:11:01 -0400	[thread overview]
Message-ID: <20150502011100.GB5634@peff.net> (raw)
In-Reply-To: <CANuW5x3OBWNDnHeVbH7ZQaj5AUAingea6crJ0cF9AHFjcJE_bQ@mail.gmail.com>

On Fri, May 01, 2015 at 08:49:14PM -0400, Josh Hagins wrote:

> If you're using a recent version of bash, you could enable the
> 'globstar' option:
> 
>     $ shopt -s globstar
>     $ git grep 'pattern' **/*.{cc,cpp,h}
> 
> Does that work?

That will only pick up files that are in the working tree. Which is fine
for a stock "git grep" with no options, but would not be right for
grepping in the index or an older tree. For that, you can ask git to
glob for you:

  git grep pattern -- '*.cc' '*.cpp' '*.h'

Note that the "--" is important (it's what tells git "these are
pathspecs and not revision names"; normally git will guess if you are
passing literal pathnames, but the glob patterns fool the guessing
machinery).

Unfortunately there is no way to use curly braces with git's pathspec,
so you have to write out three separate `*` arguments rather than using
the shell-style {cc,cpp,h}.

-Peff

  reply	other threads:[~2015-05-02  1:11 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-05-02  0:40 multiple source file extensions Thiago Farina
2015-05-02  0:49 ` Josh Hagins
2015-05-02  1:11   ` Jeff King [this message]
2015-05-02  2:04     ` Duy Nguyen
2015-05-02  2:11       ` Duy Nguyen
2015-05-02  2:35         ` Jeff King
2015-05-02  7:11           ` Eric Sunshine
2015-05-03  2:26             ` Junio C Hamano
2015-05-02  2:33       ` Jeff King
2015-05-04 22:12     ` Thiago Farina
2015-05-05  3:43       ` Jeff King
2015-05-05 17:30         ` Mikael Magnusson
2015-05-05 19:12           ` Jeff King

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=20150502011100.GB5634@peff.net \
    --to=peff@peff.net \
    --cc=git@vger.kernel.org \
    --cc=hagins.josh@gmail.com \
    --cc=tfransosi@gmail.com \
    /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).