All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jeff King <peff@peff.net>
To: Duy Nguyen <pclouds@gmail.com>
Cc: Noel Grandin <noel@peralex.com>, git <git@vger.kernel.org>
Subject: Re: feature request: excluding files/paths from "git grep"
Date: Wed, 25 Feb 2015 09:31:16 -0500	[thread overview]
Message-ID: <20150225143116.GA13567@peff.net> (raw)
In-Reply-To: <CACsJy8AM=W4f6u_7YpvmfiBwrJjqfJMJoq6CQYfKOh+qD6rF3Q@mail.gmail.com>

On Wed, Feb 25, 2015 at 08:46:37PM +0700, Duy Nguyen wrote:

> On Wed, Feb 25, 2015 at 7:23 PM, Noel Grandin <noel@peralex.com> wrote:
> > What would be nice is a per-user/repo config setting that excludes certain
> > files and paths from the 'git grep' search.
> >
> > Does this sound reasonable/acceptable?
> 
> There is no config setting to do that, but since v1.9.5 you can use
> ':!' or ':(exclude) to exclude paths, for example
> 
> git grep foo -- '*.c' ':!src/ ':!*foo*.c'
> 
> will exclude .c files in src directory or contains "foo". If you use
> some exclude patterns often, you can write a short script. Perhaps we
> could support pathspec macros (similar to git-attr macros), stored in
> config file. You still need to type, but it'll be a lot shorter.

If it's an attribute of the file, and not the request, maybe
gitattributes would be a better fit. You can already do this with:

  *.foo -diff

in your .gitattributes file, though that _also_ marks the files as "not
for diffing", which may not be desired. There's not a separate "grep"
attribute, but I do not think it would be unreasonable to add one.

-Peff

  reply	other threads:[~2015-02-25 14:31 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-02-25 12:23 feature request: excluding files/paths from "git grep" Noel Grandin
2015-02-25 13:46 ` Duy Nguyen
2015-02-25 14:31   ` Jeff King [this message]
2015-02-25 18:33     ` Junio C Hamano
2015-02-25 18:51       ` Jeff King
2015-02-25 19:01         ` Junio C Hamano
2015-02-25 19:11           ` Jeff King
2015-02-26 11:16             ` Michael J Gruber
2015-02-26 11:58               ` Duy Nguyen
2015-02-26 20:59               ` Junio C Hamano
2015-02-27 15:13                 ` Michael J Gruber
2015-02-27 19:17                   ` Junio C Hamano
2015-02-27 10:04             ` Trevor Saunders
2015-03-01  3:06               ` Junio C Hamano
2015-03-01 13:03                 ` Trevor Saunders
2015-03-01 23:22                   ` Junio C Hamano
2015-03-02 12:50                     ` Trevor Saunders
2015-03-04 11:25                       ` Noel Grandin
2015-03-04 20:56                         ` Junio C Hamano
2015-03-05  5:22                           ` Jeff King
2015-03-05  6:03                             ` 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=20150225143116.GA13567@peff.net \
    --to=peff@peff.net \
    --cc=git@vger.kernel.org \
    --cc=noel@peralex.com \
    --cc=pclouds@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.