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>maint
parent
7dbc2c0402
commit
c0c35d5e41
|
@ -39,5 +39,9 @@ while : ; do
|
||||||
esac
|
esac
|
||||||
shift
|
shift
|
||||||
done
|
done
|
||||||
|
[ "$pattern" ] || {
|
||||||
|
echo >&2 "usage: 'git grep <pattern> [pathspec*]'"
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
git-ls-files -z "${git_flags[@]}" "$@" |
|
git-ls-files -z "${git_flags[@]}" "$@" |
|
||||||
xargs -0 grep "${flags[@]}" -e "$pattern"
|
xargs -0 grep "${flags[@]}" -e "$pattern"
|
||||||
|
|
Loading…
Reference in New Issue