grep --quiet: finishing touches
Name the option "--quiet" not "--quick", document it, and add tests. Signed-off-by: Junio C Hamano <gitster@pobox.com>
Junio C Hamano committed
Jan 28, 2010 at 12:33 UTC
4ff61c21de519b4b3c9569b354fa5a3905b69c6a
3 files changed
+15
-2
Documentation/git-grep.txt
+6
-1
@@ -16,7 +16,7 @@ SYNOPSIS
16
[-F | --fixed-strings] [-n]
17
[-l | --files-with-matches] [-L | --files-without-match]
18
[-z | --null]
19
- [-c | --count] [--all-match]
19
+ [-c | --count] [--all-match] [-q | --quiet]
20
[--max-depth <depth>]
21
[--color | --no-color]
22
[-A <post-context>] [-B <pre-context>] [-C <context>]
@@ -158,6 +158,11 @@ OPTIONS
158
this flag is specified to limit the match to files that
159
have lines to match all of them.
160
161
+-q::
162
+--quiet::
163
+ Do not output matched lines; instead, exit with status 0 when
164
+ there is a match and with non-zero status when there isn't.
165
+
166
`<tree>...`::
167
Search blobs in the trees for specified patterns.
168
builtin-grep.c
+1
-1
@@ -832,7 +832,7 @@ int cmd_grep(int argc, const char **argv, const char *prefix)
832
{ OPTION_CALLBACK, ')', NULL, &opt, NULL, "",
833
PARSE_OPT_NOARG | PARSE_OPT_NONEG | PARSE_OPT_NODASH,
834
close_callback },
835
- OPT_BOOLEAN('q', "quick", &opt.status_only,
835
+ OPT_BOOLEAN('q', "quiet", &opt.status_only,
836
"indicate hit with exit status without output"),
837
OPT_BOOLEAN(0, "all-match", &opt.all_match,
838
"show only matches from files that match all patterns"),
t/t7002-grep.sh
+8
@@ -291,6 +291,14 @@ y:y yy
291
z:zzz
292
EOF
293
294
+test_expect_success 'grep -q, silently report matches' '
295
+ >empty &&
296
+ git grep -q mmap >actual &&
297
+ test_cmp empty actual &&
298
+ test_must_fail git grep -q qfwfq >actual &&
299
+ test_cmp empty actual
300
+'
301
+
302
# Create 1024 file names that sort between "y" and "z" to make sure
303
# the two files are handled by different calls to an external grep.
304
# This depends on MAXARGS in builtin-grep.c being 1024 or less.