Re: feature request: excluding files/paths from "git grep"

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxx> 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
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]