path: root/grep.c
diff options
authorJunio C Hamano <>2010-01-25 23:37:23 (GMT)
committerJunio C Hamano <>2010-01-25 23:42:55 (GMT)
commitc8610a2e7eca60a060f719f0aeb20f146e339de4 (patch)
tree2099d59cbeb047717342a1c175a9e61543161c82 /grep.c
parent2d7f98bac7e1d8b42c558e179ea24f5b06512622 (diff)
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 <>
Diffstat (limited to 'grep.c')
0 files changed, 0 insertions, 0 deletions