git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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

From
Jeff King <peff@peff.net>
Date
Feb 25, 2015, 18:51 UTC
Message-ID
<20150225185128.GA16569@peff.net>
In-Reply-To
<xmqqk2z5on72.fsf@gitster.dls.corp.google.com>
On Wed, Feb 25, 2015 at 10:33:53AM -0800, Junio C Hamano wrote:
Show 17 quoted lines
> Jeff King <peff@peff.net> writes:
> 
> > 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.
> 
> I have a vague recollection of having a discussion that started with
> something like this:
> 
>     "diff" is named as if it is only for "diff" for historical
>     reasons, but it is about "do we want to treat its raw contents
>     as text?"

Yes, I think we had this discussion, and agreed that is a reasonable definition...

Show 5 quoted lines
> I do not recall its conclusion, but it it were "Yes, that is what it
> means", then it might be reasonable to:
> 
>  - have "git grep" ignore paths marked with -diff by default
>    (perhaps "-a" option to disable, just like GNU)

...which led to 41b59bf (grep: respect diff attributes for binary-ness, 2012-02-02)...

>  - have "git grep" pay attention to diff.textconv and search in the
>    result of textconv filter.
..and 335ec3b (grep: allow to use textconv filters, 2013-05-10).

So I think _if_ using "diff" attributes is enough for this purpose, then there is no code to be written. But if somebody wants to draw a distinction between the uses (I want to diff "foo" files, but never see them in grep) then we could introduce a "grep" attribute (with the fallback being the value of the "diff" attribute for that path).

-Peff
Previous: Junio C HamanoNext: Junio C Hamano
Message 5 of 21 in “feature request: excluding files/paths from "git grep"”
  1. Noel GrandinFeb 25, 2015
  2. Duy NguyenFeb 25, 2015
  3. Jeff KingFeb 25, 2015
  4. Junio C HamanoFeb 25, 2015
  5. Jeff KingFeb 25, 2015
  6. Junio C HamanoFeb 25, 2015
  7. Jeff KingFeb 25, 2015
  8. Michael J GruberFeb 26, 2015
  9. Duy NguyenFeb 26, 2015
  10. Junio C HamanoFeb 26, 2015
  11. Michael J GruberFeb 27, 2015
  12. Junio C HamanoFeb 27, 2015
  13. Trevor SaundersFeb 27, 2015
  14. Junio C HamanoMar 1, 2015
  15. Trevor SaundersMar 1, 2015
  16. Junio C HamanoMar 1, 2015
  17. Trevor SaundersMar 2, 2015
  18. Noel GrandinMar 4, 2015
  19. Junio C HamanoMar 4, 2015
  20. Jeff KingMar 5, 2015
  21. Junio C HamanoMar 5, 2015

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.