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
MGMario Grgic <mario_grgic@hotmail.com>
Date
Mar 28, 2023, 00:03 UTC
Message-ID
<MW4PR20MB5517CBF944D108A95665025A90889@MW4PR20MB5517.namprd20.prod.outlook.com>
In-Reply-To
<xmqqtty5nbm4.fsf@gitster.g>
Interesting. I could be wrong. Let me clarify what I did and what I observe. I edited the Makefile and put back the NO_REGEX = YesPlease line. Then I configured the build as 
./configure —with-libpcre2=/usr/local 
then built and installed git. 
otool -L git shows git binary is dynamically linking the libpcre in /usr/local
However, it looks like this third party library is also used for -G  searches (plain POSIX regex or PCRE), since it accepts and correctly finds things like ‘\btext\b’. That is 
git log —all -p -G ‘\main\b’
works
Furthermore, -G works with multibyte strings as well: 
git log --all -p  -G '顔🏁’
What doesn’t work is multibyte strings with PCRESs, so for example this does not work:
git log --all -p  -G ‘\b顔🏁\b’
This doesn’t seem to be consistent with the thesis that regex library from compat is used for -G searches and that it doesn’t support multibyte strings?
Show 28 quoted lines
> On Mar 27, 2023, at 5:11 PM, Junio C Hamano <gitster@pobox.com> wrote:
> 
> Mario Grgic <mario_grgic@hotmail.com> writes:
> 
> [administrivia: do not top post]
> 
>>> Mario Grgic <mario_grgic@hotmail.com> writes:
>>> ...
>>>> +	NO_REGEX = YesPlease
>>>> 	PTHREAD_LIBS =
>>>> endif
>>> 
>>> It will unfortunately break multibyte support on macOS by reverting
>>> what 1819ad32 (grep: fix multibyte regex handling under macOS,
>>> 2022-08-26) did.
> 
>> In my case, I compiled git with pcre2 support, using third party
>> PCRE2 library: https://github.com/PCRE2Project/pcre2 and PCRE and
>> multibyte support in git works with it just fine.
> 
> Sorry, you misunderstood.  1819ad32 is about enabling multi-byte
> support for normal regexp types, and does not have anything to do
> with pcre.  By setting NO_REGEX, the build will not link with
> Apple's regex library but the one from compat/ and that version is
> what is used for -G and -E (not -P).  -G/-E patterns with multi-byte
> would not work with compat/ stuff, but they should work when linked
> with Apple's regex library.
> 
Previous: Junio C Hamano
Message 18 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.