grep --quiet: finishing touches

Name the option "--quiet" not "--quick", document it, and add tests.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Junio C Hamano
2010-01-28 12:33:42 -08:00
parent 12a258c078
commit 4ff61c21de
3 changed files with 15 additions and 2 deletions

View File

@ -16,7 +16,7 @@ SYNOPSIS
[-F | --fixed-strings] [-n] [-F | --fixed-strings] [-n]
[-l | --files-with-matches] [-L | --files-without-match] [-l | --files-with-matches] [-L | --files-without-match]
[-z | --null] [-z | --null]
[-c | --count] [--all-match] [-c | --count] [--all-match] [-q | --quiet]
[--max-depth <depth>] [--max-depth <depth>]
[--color | --no-color] [--color | --no-color]
[-A <post-context>] [-B <pre-context>] [-C <context>] [-A <post-context>] [-B <pre-context>] [-C <context>]
@ -158,6 +158,11 @@ OPTIONS
this flag is specified to limit the match to files that this flag is specified to limit the match to files that
have lines to match all of them. have lines to match all of them.
-q::
--quiet::
Do not output matched lines; instead, exit with status 0 when
there is a match and with non-zero status when there isn't.
`<tree>...`:: `<tree>...`::
Search blobs in the trees for specified patterns. Search blobs in the trees for specified patterns.

View File

@ -832,7 +832,7 @@ int cmd_grep(int argc, const char **argv, const char *prefix)
{ OPTION_CALLBACK, ')', NULL, &opt, NULL, "", { OPTION_CALLBACK, ')', NULL, &opt, NULL, "",
PARSE_OPT_NOARG | PARSE_OPT_NONEG | PARSE_OPT_NODASH, PARSE_OPT_NOARG | PARSE_OPT_NONEG | PARSE_OPT_NODASH,
close_callback }, close_callback },
OPT_BOOLEAN('q', "quick", &opt.status_only, OPT_BOOLEAN('q', "quiet", &opt.status_only,
"indicate hit with exit status without output"), "indicate hit with exit status without output"),
OPT_BOOLEAN(0, "all-match", &opt.all_match, OPT_BOOLEAN(0, "all-match", &opt.all_match,
"show only matches from files that match all patterns"), "show only matches from files that match all patterns"),

View File

@ -291,6 +291,14 @@ y:y yy
z:zzz z:zzz
EOF EOF
test_expect_success 'grep -q, silently report matches' '
>empty &&
git grep -q mmap >actual &&
test_cmp empty actual &&
test_must_fail git grep -q qfwfq >actual &&
test_cmp empty actual
'
# Create 1024 file names that sort between "y" and "z" to make sure # Create 1024 file names that sort between "y" and "z" to make sure
# the two files are handled by different calls to an external grep. # the two files are handled by different calls to an external grep.
# This depends on MAXARGS in builtin-grep.c being 1024 or less. # This depends on MAXARGS in builtin-grep.c being 1024 or less.