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

Re: git bug: Perl compatible regular expressions do not work as expected

From
Junio C Hamano <gitster@pobox.com>
Date
Mar 27, 2023, 16:29 UTC
Message-ID
<xmqqh6u6cg4l.fsf@gitster.g>
In-Reply-To
<eba23dc4-c036-fd1b-a1f0-028e8fff602b@web.de>
René Scharfe <l.s.r@web.de> writes:
Show 12 quoted lines
> Am 25.03.23 um 14:09 schrieb Mario Grgic:
>> The lowercase -p is to print the output in patch format. You can rewrite the command line as
>>
>>  git log --all --patch --perl-regexp -G '\bmain\b’
>>
>> I still get no output in any git version after 2.38.4
>
> -G doesn't support Perl regular expressions.  --perl-regexp only affects
> --grep, --grep-reflog, --author, and --committer.  Neither POSIX basic
> nor extended regular expressions support \b as word boundary.  GNU regex
> and our compat/regex/ do, as extensions.  macOS regex supports it if the
> flag REG_ENHANCED is given to regcomp(3).
Good summary to unconfuse speculations in the thread.
> So perhaps this is rather a feature request to support Perl regular
> expressions for -G (and probably -S as well).  

Perhaps. I used to be a "it would be wonderful if pcre were usable everywhere" dreamer, but after seeing our share of bugs caused by use of pcre, I am not a huge proponent anymore. I do not object to such an enhancement at all, as long as it is done cleanly and in such a way that it is clear pcre cannot be used by accident when the user does not ask for it.

> Or to enable REG_ENHANCED
> for them, at least, like 54463d32ef (use enhanced basic regular
> expressions on macOS, 2023-01-08) did to get alternations for git grep
> on macOS.

This one sounds like a reasonable thing, which may not have huge unintended fallout, to do. I am a bit surprised that we have to cover each individual callsite of regcomp(3), though. Doesn't the 54463d32ef fix use "#define regcomp git_regcomp" to cover everybody?

Previous: René ScharfeNext: René Scharfe
Message 8 of 18 in “git bug: Perl compatible regular expressions do not work as expected”
  1. Mario GrgicMar 25, 2023
  2. Kristoffer HaugsbakkMar 25, 2023
  3. Mario GrgicMar 25, 2023
  4. demerphqMar 25, 2023
  5. Mario GrgicMar 25, 2023
  6. demerphqMar 25, 2023
  7. René ScharfeMar 25, 2023
  8. Junio C HamanoMar 27, 2023
  9. René ScharfeMar 27, 2023
  10. Junio C HamanoMar 27, 2023
  11. Junio C HamanoMar 28, 2023
  12. René ScharfeMar 28, 2023
  13. Mario GrgicMar 25, 2023
  14. Mario GrgicMar 25, 2023
  15. Junio C HamanoMar 27, 2023
  16. Mario GrgicMar 27, 2023
  17. Junio C HamanoMar 27, 2023
  18. Mario GrgicMar 28, 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.