From: Jeff King Date: Fri, 26 Jan 2007 04:56:40 GMT Subject: Re: [PATCH] diffcore-pickaxe: fix infinite loop on zero-length needle 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: > 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