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

Re: BUG: git grep behave oddly with alternatives

From
René Scharfe <l.s.r@web.de>
Date
Jan 4, 2023, 16:36 UTC
Message-ID
<e5165840-331c-e9b6-b45f-62abab860d79@web.de>
In-Reply-To
<Y7Uu35HwUx2EVfAg@coredump.intra.peff.net>
Am 04.01.23 um 08:46 schrieb Jeff King:
Show 28 quoted lines
> On Tue, Jan 03, 2023 at 09:52:27PM +0100, René Scharfe wrote:
>
>> diff --git a/Makefile b/Makefile
>> index db447d0738..15e7edc9d2 100644
>> --- a/Makefile
>> +++ b/Makefile
>> @@ -289,6 +289,10 @@ include shared.mak
>>  # Define NO_REGEX if your C library lacks regex support with REG_STARTEND
>>  # feature.
>>  #
>> +# Define GIT_GREP_USES_REG_ENHANCED if your C library provides the flag
>> +# REG_ENHANCED to enable enhanced basic regular expressions and you'd
>> +# like to use it in git grep.
>
> I didn't test, but just from looking at the patch I'd expect this to
> affect other parts of Git besides git-grep. E.g., "git log --grep".
> Which raises two questions:
>
>  - would a more generalized name be better? USE_REG_ENHANCED or
>    something? That might be _too_ general, but see below.
>
>  - should this cover other cases? Grepping for "regcomp", would people
>    want this to behave consistently for "git config --get-regexp", or
>    diff funcnames, and so on?
>
> If so, then I could envision a USE_REG_ENHANCED which just wraps the
> system regcomp and adds the REG_ENHANCED flag when REG_EXTENDED is not
> set?

Good point. I don't know what people want, though. re_format(7) on macOS/BSD and regex(7) on Linux call basic REs "obsolete" and extended REs "modern", so they seem to push people away from the old kind, enhanced or not.

But making a consistent choice for all regex use makes sense -- platforms that use compat/regex/ get the same enhanced flavor everywhere.

René
Previous: Jeff KingNext: Jeff King
Message 7 of 22 in “BUG: git grep behave oddly with alternatives”
  1. Marco NenciariniJan 3, 2023
  2. René ScharfeJan 3, 2023
  3. Marco NenciariniJan 3, 2023
  4. René ScharfeJan 3, 2023
  5. Junio C HamanoJan 4, 2023
  6. Jeff KingJan 4, 2023
  7. René ScharfeJan 4, 2023
  8. Jeff KingJan 6, 2023
  9. René ScharfeJan 8, 2023
  10. Junio C HamanoJan 8, 2023
  11. Jeff KingJan 11, 2023
  12. René ScharfeJan 12, 2023
  13. Ævar Arnfjörð BjarmasonJan 12, 2023
  14. Jeff KingJan 12, 2023
  15. Ævar Arnfjörð BjarmasonJan 13, 2023
  16. Junio C HamanoJan 13, 2023
  17. René ScharfeJan 14, 2023
  18. René ScharfeJan 14, 2023
  19. Diomidis SpinellisJan 14, 2023
  20. Junio C HamanoJan 14, 2023
  21. René ScharfeJan 13, 2023
  22. René ScharfeJan 13, 2023

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.