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

Re: multiple source file extensions

From
Jeff King <peff@peff.net>
Date
May 5, 2015, 19:12 UTC
Message-ID
<20150505191238.GC10463@peff.net>
In-Reply-To
<CAHYJk3TzZd8N6E+=nNi1jR36Zc5A7be8ZPL9jLU7c8uAdQJYBw@mail.gmail.com>
On Tue, May 05, 2015 at 07:30:00PM +0200, Mikael Magnusson wrote:
Show 17 quoted lines
> >> ".*\.[cChH]\(pp\)?"
> >
> > No, pathspecs are globs, not regexps. I think the idea has been floated
> > for supporting regexps, which you would activate something like:
> >
> >   git grep pattern -- :(regexp)$your_regex_here
> >
> > but nobody has implemented it. I'm not sure it actually saves you any
> > typing (besides which, your regexp does not match ".cc", which was in
> > the original).
> 
> Remember that the more bells and whistles you add to pathspecs, the
> less actual filenames can be conveniently tracked by git; *.c will be
> expanded by the shell and passed literally to git, and if git then
> interprets a bunch of stuff again, you could end up with a false
> negative or positive match. Obviously files with * and ? in them are
> already unsupported, try not to add more.

I agree this is a problem, but I think we have already crossed that bridge, and going forward:

  1. Any new bells and whistles will have to be activated explicitly
     (that's what the ":(regexp)" syntax is).
  2. The ":()" magic is already there, so add it to "*" and "?" in the
     list of obstacles.
  3. There is ":(literal)", "--literal-pathspecs", and $GIT_LITERAL_PATHSPECS
     to turn off all magic.
-Peff
Previous: Mikael Magnusson
Message 13 of 13 in “multiple source file extensions”
  1. Thiago FarinaMay 2, 2015
  2. Josh HaginsMay 2, 2015
  3. Jeff KingMay 2, 2015
  4. Duy NguyenMay 2, 2015
  5. Duy NguyenMay 2, 2015
  6. Jeff KingMay 2, 2015
  7. Eric SunshineMay 2, 2015
  8. Junio C HamanoMay 3, 2015
  9. Jeff KingMay 2, 2015
  10. Thiago FarinaMay 4, 2015
  11. Jeff KingMay 5, 2015
  12. Mikael MagnussonMay 5, 2015
  13. Jeff KingMay 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.