author | Jeff King <peff@peff.net> | |
Fri, 26 Jan 2007 04:48:58 +0000 (23:48 -0500) | ||
committer | Junio C Hamano <junkio@cox.net> | |
Fri, 26 Jan 2007 05:17:19 +0000 (21:17 -0800) | ||
commit | e1b161161d253a9e7e4cf21cd2ab5b82a4b85273 | |
tree | b9adbfc7986c01d9e77d3e46f4af7ca42009e90e | tree | snapshot |
parent | cb280e107523e5263f390db715234700355a63b9 | commit | diff |
diffcore-pickaxe: fix infinite loop on zero-length needle
The "contains" algorithm runs into an infinite loop if the needle string
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.
Arguably, an empty pickaxe string should simply produce an error
message; however, this is still a useful assertion to add to the
algorithm at this layer of the code.
Noticed by Bill Lear.
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <junkio@cox.net>
The "contains" algorithm runs into an infinite loop if the needle string
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.
Arguably, an empty pickaxe string should simply produce an error
message; however, this is still a useful assertion to add to the
algorithm at this layer of the code.
Noticed by Bill Lear.
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <junkio@cox.net>
diffcore-pickaxe.c | diff | blob | history |