author | René Scharfe <rene.scharfe@lsrfire.ath.cx> | |
Wed, 3 Jun 2009 16:19:01 +0000 (18:19 +0200) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Wed, 3 Jun 2009 18:32:29 +0000 (11:32 -0700) | ||
commit | 84201eae771fbb1d774cf1356d89016053e56778 | |
tree | 050ff75bc770f991d008fbb55abd8cf5a6901fd7 | tree | snapshot |
parent | a9b2d42486ee0b461220bf3895114926d9ddf9be | commit | diff |
grep: fix empty word-regexp matches
The command "git grep -w ''" dies as soon as it encounters an empty line,
reporting (wrongly) that "regexp returned nonsense". The first hunk of
this patch relaxes the sanity check that is responsible for that,
allowing matches to start at the end.
The second hunk complements it by making sure that empty matches are
rejected if -w was specified, as they are not really words.
GNU grep does the same:
$ echo foo | grep -c ''
1
$ echo foo | grep -c -w ''
0
Signed-off-by: Rene Scharfe <rene.scharfe@lsrfire.ath.cx>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
The command "git grep -w ''" dies as soon as it encounters an empty line,
reporting (wrongly) that "regexp returned nonsense". The first hunk of
this patch relaxes the sanity check that is responsible for that,
allowing matches to start at the end.
The second hunk complements it by making sure that empty matches are
rejected if -w was specified, as they are not really words.
GNU grep does the same:
$ echo foo | grep -c ''
1
$ echo foo | grep -c -w ''
0
Signed-off-by: Rene Scharfe <rene.scharfe@lsrfire.ath.cx>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
grep.c | diff | blob | history |