Disallow empty pattern in "git grep"
For some reason I've done a "git grep" twice with no pattern, which is really irritating, since it just grep everything. If I actually wanted that, I could do "git grep ^" or something. So add a "usage" message if the pattern is empty. Signed-off-by: Linus Torvalds <torvalds@osdl.org> Signed-off-by: Junio C Hamano <junkio@cox.net>
Linus Torvalds committed
Nov 16, 2005 at 09:38 UTC
c0c35d5e419f3bf215103b1e26359aca288c2113
1 file changed
+4
git-grep.sh
+4
@@ -39,5 +39,9 @@ while : ; do
39
esac
40
shift
41
done
42
+[ "$pattern" ] || {
43
+ echo >&2 "usage: 'git grep <pattern> [pathspec*]'"
44
+ exit 1
45
+}
46
git-ls-files -z "${git_flags[@]}" "$@" |
47
xargs -0 grep "${flags[@]}" -e "$pattern"