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

Re: [PATCH v7 1/2] grep: refactor next_match() and match_one_pattern() for external use

From
Hamza Mahfooz <someguy@effective-light.com>
Date
Sep 24, 2021, 12:04 UTC
Message-ID
<HJTXZQ.ONLOCDR1B7O51@effective-light.com>
In-Reply-To
<xmqq8rzn2ohj.fsf@gitster.g>

On Thu, Sep 23 2021 at 10:25:28 AM -0700, Junio C Hamano <gitster@pobox.com> wrote:

Show 15 quoted lines
> But how would the new caller that points "bol" at middle of a line
> make sure that we are looking at the right kind of header?  If the
> pattern p is set to match only for an author line, the first call
> with "bol" set to the true beginning of the line will correctly
> reject a "committer" header, but because you lost the sanity check
> above, the second and subsequent one will go ahead and scan for the
> pattern p on the line, even if p->field asks for author line and the
> line records the committer.  You'd end up finding a commit object
> that is committed by (but not authored by) the person when you are
> looking for a commit that was authored by somebody, no?
> 
> If you ask for commits by somebody (e.g. "--author=Hazma") with an
> output format that shows both the author and the committer
> (e.g. "log --pretty=fuller"), wouldn't your "hit coloring" code
> show Hazma on the committer name as a grep hit, too?

Actually, this issue doesn't arise because I filter away the irrelevant (header) patterns in grep_next_match(). However, maybe it's a better idea to handle that in match_one_pattern().

Previous: Junio C Hamano
Message 4 of 4 in “grep: refactor next_match() and match_one_pattern() for external use”
  1. 1/2 grep: refactor next_match() and match_one_pattern() for external useHamza Mahfooz, Sep 21, 2021
  2. 2/2 pretty: colorize pattern matches in commit messagesHamza Mahfooz, Sep 21, 2021
  3. Junio C HamanoSep 23, 2021
  4. Hamza MahfoozSep 24, 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.