diff options
author | Junio C Hamano <gitster@pobox.com> | 2010-01-25 15:37:23 -0800 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2010-01-25 15:42:55 -0800 |
commit | c8610a2e7eca60a060f719f0aeb20f146e339de4 (patch) | |
tree | 2099d59cbeb047717342a1c175a9e61543161c82 /t/t5515/refs.br-remote-explicit | |
parent | commit-tree: remove unused #define (diff) | |
download | tgif-c8610a2e7eca60a060f719f0aeb20f146e339de4.tar.xz |
grep: expose "status-only" feature via -q
Teach "git grep" a new "-q" option to report the presense of a match via
its exit status without showing any output, similar to how "grep -q"
works. Internally "grep" engine already knew this "status-only" mode of
operation because it needed to grep inside log message to filter commits
when called from the "git log" machinery, and this patch only exposes it
to the command line tool.
A somewhat unfair benchmark in the Linux kernel directory shows a dramatic
improvement:
(with patch)
$ time ../git.git/git grep -q linux HEAD ; echo $?
real 0m0.030s
user 0m0.004s
sys 0m0.004s
0
(without patch)
$ time git grep linux HEAD >/dev/null; echo $?
real 0m4.432s
user 0m4.272s
sys 0m0.076s
0
This is "somewhat unfair" because I knew a file with such a string comes
very early in the tree traversal (namely, ".gitignore").
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/t5515/refs.br-remote-explicit')
0 files changed, 0 insertions, 0 deletions