Skip to content

Commit 4ff61c2

Browse files
committed
grep --quiet: finishing touches
Name the option "--quiet" not "--quick", document it, and add tests. Signed-off-by: Junio C Hamano <[email protected]>
1 parent 12a258c commit 4ff61c2

File tree

3 files changed

+15
-2
lines changed

3 files changed

+15
-2
lines changed

Documentation/git-grep.txt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ SYNOPSIS
1616
[-F | --fixed-strings] [-n]
1717
[-l | --files-with-matches] [-L | --files-without-match]
1818
[-z | --null]
19-
[-c | --count] [--all-match]
19+
[-c | --count] [--all-match] [-q | --quiet]
2020
[--max-depth <depth>]
2121
[--color | --no-color]
2222
[-A <post-context>] [-B <pre-context>] [-C <context>]
@@ -158,6 +158,11 @@ OPTIONS
158158
this flag is specified to limit the match to files that
159159
have lines to match all of them.
160160

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+
161166
`<tree>...`::
162167
Search blobs in the trees for specified patterns.
163168

builtin-grep.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -832,7 +832,7 @@ int cmd_grep(int argc, const char **argv, const char *prefix)
832832
{ OPTION_CALLBACK, ')', NULL, &opt, NULL, "",
833833
PARSE_OPT_NOARG | PARSE_OPT_NONEG | PARSE_OPT_NODASH,
834834
close_callback },
835-
OPT_BOOLEAN('q', "quick", &opt.status_only,
835+
OPT_BOOLEAN('q', "quiet", &opt.status_only,
836836
"indicate hit with exit status without output"),
837837
OPT_BOOLEAN(0, "all-match", &opt.all_match,
838838
"show only matches from files that match all patterns"),

t/t7002-grep.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,14 @@ y:y yy
291291
z:zzz
292292
EOF
293293

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+
294302
# Create 1024 file names that sort between "y" and "z" to make sure
295303
# the two files are handled by different calls to an external grep.
296304
# This depends on MAXARGS in builtin-grep.c being 1024 or less.

0 commit comments

Comments
 (0)