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

Re: macOS git grep change in required character classes

From
MGMatt Gardner <four712@gmail.com>
Date
Apr 1, 2023, 17:17 UTC
Message-ID
<CA+MNPvg9JX8S2fOcH9NEq=d04BcCgbf5Qwc070WWwjXpUsd3Sw@mail.gmail.com>
In-Reply-To
<xmqqa5zrbmap.fsf@gitster.g>
Even though the grep that ships with macOS is GNU compatible?

$ which grep /usr/bin/grep $ grep -V grep (BSD grep) 2.5.1-FreeBSD $ grep -E \\btest\\b test.pl sub test { return; }

So, it isn't quite true that it makes it like other tools, especially the most analogous tool, grep itself.

I think it would be a reasonable expectation that git grep and system grep behave in the same manner.

On Sat, Apr 1, 2023 at 12:27 PM Junio C Hamano <gitster@pobox.com> wrote:
Show 22 quoted lines
>
> Matt Gardner <four712@gmail.com> writes:
>
> > My best guess is that
> > https://github.com/git/git/commit/1819ad327b7a1f19540a819813b70a0e8a7f798f
> > is causing git grep -E to require BSD style regular expression
> > character classes.  I don't know if this is a bug or an unadvertised
> > change in behavior.
>
> I think you diagnosed it correctly.  The story is "Once upon a time,
> we declared that the regex library of macOS is so broken and
> unusable.  We used a fallback definition to work it around, but
> unfortunately the fallback library did not support multi-byte
> matching correctly, which made some folks on macOS unhappy.  So we
> let Git built with the regex library shipped with macOS starting
> that commit, with one side effect that patterns you would feed Git
> on that platform would behave more like patterns you give to other
> tools on the platform."
>
> So, it is not a bug in Git, it is a deliberate change in behaviour
> with unintended consequences X-<.
>
Previous: Junio C HamanoNext: Junio C Hamano
Message 3 of 4 in “macOS git grep change in required character classes”
  1. Matt GardnerApr 1, 2023
  2. Junio C HamanoApr 1, 2023
  3. Matt GardnerApr 1, 2023
  4. Junio C HamanoApr 1, 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.