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

Re: [PATCH v11 3/3] grep: fix an edge case concerning ascii patterns and UTF-8 data

From
Junio C Hamano <gitster@pobox.com>
Date
Oct 8, 2021, 21:26 UTC
Message-ID
<xmqq1r4vjji3.fsf@gitster.g>
In-Reply-To
<20211007203148.23888-3-someguy@effective-light.com>
Hamza Mahfooz <someguy@effective-light.com> writes:
Show 9 quoted lines
> If we attempt to grep non-ascii log message text with an ascii pattern, we
> run into the following issue:
>
>     $ git log --color --author='.var.*Bjar' -1 origin/master | grep ^Author
>     grep: (standard input): binary file matches
>
> So, to fix this teach the grep code to mark the pattern as UTF-8 (even if
> the pattern is composed of only ascii characters), so long as the log
> output is encoded using UTF-8.

We'd need this only if we are using pcre2 backend, no? If that is the case, that fact needs to be recorded in the proposed log message to help later developers, when they wonder why this "all-the-things" knob exists.

And if it is the case that this bit is needed only to work around a glitch while using pcre2 backend, I'd rather want to see a solution that does not need to contaminate the more generic "struct grep_opt" data and "setup_revisions()" codepath.

In other words, can't the function compile_pcre2_pattern() make the "is log output encoding utf8?" decision locally and act accordingly?

Thanks.
Previous: Hamza MahfoozNext: Junio C Hamano
Message 4 of 6 in “grep: refactor next_match() and match_one_pattern() for external use”
  1. 1/3 grep: refactor next_match() and match_one_pattern() for external useHamza Mahfooz, Oct 7, 2021
  2. 2/3 pretty: colorize pattern matches in commit messagesHamza Mahfooz, Oct 7, 2021
  3. 3/3 grep: fix an edge case concerning ascii patterns and UTF-8 dataHamza Mahfooz, Oct 7, 2021
  4. Junio C HamanoOct 8, 2021
  5. Junio C HamanoOct 9, 2021
  6. Hamza MahfoozOct 9, 2021

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.