]> git.ipfire.org Git - thirdparty/git.git/commit - diffcore-pickaxe.c
pickaxe: assert that we must have a needle under -G or -S
authorÆvar Arnfjörð Bjarmason <avarab@gmail.com>
Mon, 12 Apr 2021 17:15:20 +0000 (19:15 +0200)
committerJunio C Hamano <gitster@pobox.com>
Tue, 11 May 2021 03:47:31 +0000 (12:47 +0900)
commit2e197a759221921d42c5e94ae3f4897cd456ebb4
tree967fd6f168b04e81be588b6dbfa083aaaad0adea
parent03c1f14acf5169d8e6c06a60c28ee5a6cfb9fd54
pickaxe: assert that we must have a needle under -G or -S

Assert early in diffcore_pickaxe() that we've got a needle to work
with under -G and -S.

This code is redundant to the check -G and -S get from
parse-options.c's get_arg(), which I'm adding a test for.

This check dates back to e1b161161d (diffcore-pickaxe: fix infinite
loop on zero-length needle, 2007-01-25) when "git log -S" could send
this code into an infinite loop.

It was then later refactored in 8fa4b09fb1 (pickaxe: hoist empty
needle check, 2012-10-28) into its current form, but it seemingly
wasn't noticed that in the meantime a move to the parse-options.c API
in dea007fb4c (diff: parse separate options like -S foo, 2010-08-05)
had made it redundant.

Let's retain some of the paranoia here with a BUG(), but there's no
need to be checking this in the pickaxe_match() inner loop.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
diffcore-pickaxe.c
t/t4209-log-pickaxe.sh