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

Re: [PATCH] diffcore-pickaxe: fix infinite loop on zero-length needle

From
Jeff King <peff@peff.net>
Date
Jan 26, 2007, 04:56 UTC
Message-ID
<20070126045639.GA9260@coredump.intra.peff.net>
In-Reply-To
<20070126044858.GA8653@coredump.intra.peff.net>
On Thu, Jan 25, 2007 at 11:48:58PM -0500, Jeff King wrote:
Show 10 quoted lines
> has zero length. The loop could be modified to handle this, but it makes
> more sense to simply have an empty needle return no matches. Thus, a
> command like
>   git log -S
> produces no output.
> 
> We place the check at the top of the function so that we get the same
> results with or without --pickaxe-regex. Note that until now,
>   git log -S --pickaxe-regex
> would match everything, not nothing.

My assumption is that nobody is really depending on this behavior (since, after all, without --pickaxe-regex it caused an infinite loop!). If you want to maintain consistency, the conditional should simply return 1 instead of 0 (no callers of contains() actually care about the count value).

-Peff
Previous: Jeff KingNext: Junio C Hamano
Message 2 of 3 in “diffcore-pickaxe: fix infinite loop on zero-length needle”
  1. diffcore-pickaxe: fix infinite loop on zero-length needleJeff King, Jan 26, 2007
  2. Jeff KingJan 26, 2007
  3. Junio C HamanoJan 26, 2007

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.