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

macOS git grep change in required character classes

From
MGMatt Gardner <four712@gmail.com>
Date
Apr 1, 2023, 15:50 UTC
Message-ID
<CA+MNPvgceR3s30LaCS716NGw+8S47CQZTqFno=vE2XAuiBA7Kw@mail.gmail.com>
Thank you for filling out a Git bug report!
Please answer the following questions to help us understand your issue.
What did you do before the bug happened? (Steps to reproduce your issue)

$ mkdir git-grep-test $ cd git-grep-test $ git init $ echo "sub test { return; }" > test.pl $ git grep --untracked -E \\btest\\b

What did you expect to happen? (Expected behavior)
It should find the results like the following:
test.pl:sub test { return; }
What happened instead? (Actual behavior)
No results found
What's different between what you expected and what actually happened?
To get results, you have to use BSD style character classes:
$ git grep --untracked -E \[\[:\<:\]\]test\[\[:\>:\]\]
test.pl:sub test { return; }
Anything else you want to add:

Testing in both git 2.24 and 2.34 (the only other version I have access to at the moment), \\b and other GNU style character classes return results.

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. In either case, it is frustrating. Any person or tool would have to know which version of git they have and which operating system they are on to get results.

Please review the rest of the bug report below.

You can delete any lines you don't wish to share. [System Info] git version: git version 2.40.0 cpu: x86_64 no commit associated with this build sizeof-long: 8 sizeof-size_t: 8 shell-path: /bin/sh feature: fsmonitor--daemon uname: Darwin 19.6.0 Darwin Kernel Version 19.6.0: Tue Jun 21 21:18:39 PDT 2022; root:xnu-6153.141.66~1/RELEASE_X86_64 x86_64 compiler info: clang: 12.0.0 (clang-1200.0.32.29) libc info: no libc information available $SHELL (typically, interactive shell): /bin/bash

[Enabled Hooks]
Next: Junio C Hamano
Message 1 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.