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

git grep does not find all occurrences on macOS

From
DGDavid Gstir <david@sigma-star.at>
Date
Oct 14, 2024, 13:34 UTC
Message-ID
<771C9C4E-45F1-4F71-B3A9-4E8E4A9CAC1F@sigma-star.at>
Hi!
I encountered rather subtle issue on in git 2.47.0 on macOS 14.7 (installed from Homebrew):

git grep will not find all occurrences of string patterns containing a “.” under some conditions. In my case I have an ISO-8859 encoded text file which contains umlauts. If the string I’m grepping for occurs after a non-ASCII character in this file, git grep will not find it.

I’ve put up a reproducer here https://github.com/iokill/repro-git-grep-issue, but the gist of it is "git grep quz.baz" on the ISO-8859-encoded file below will not return anything, when it should return the line "quz.baz=3":

-->8------------- foo=bar umlauts=äöü quz.baz=3 --8<-------------

From what I’ve found so far, this occurs on macOS, but not on Linux and it has to be connected to the regex matching code, because the issue does not occur with --fixed-strings or --perl-regexp.

Thanks!
- David
Next: Taylor Blau
Message 1 of 6 in “git grep does not find all occurrences on macOS”
  1. David GstirOct 14, 2024
  2. Taylor BlauOct 15, 2024
  3. René ScharfeOct 15, 2024
  4. grep: disable lookahead on errorRené Scharfe, Oct 20, 2024
  5. Taylor BlauOct 21, 2024
  6. David GstirOct 22, 2024

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.