Anonymous avatar Anonymous committed 4ff61c2

grep --quiet: finishing touches

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

Signed-off-by: Junio C Hamano <gitster@pobox.com>;

Comments (0)

Files changed (3)

Documentation/git-grep.txt

 	   [-F | --fixed-strings] [-n]
 	   [-l | --files-with-matches] [-L | --files-without-match]
 	   [-z | --null]
-	   [-c | --count] [--all-match]
+	   [-c | --count] [--all-match] [-q | --quiet]
 	   [--max-depth <depth>]
 	   [--color | --no-color]
 	   [-A <post-context>] [-B <pre-context>] [-C <context>]
 	this flag is specified to limit the match to files that
 	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>...`::
 	Search blobs in the trees for specified patterns.
 
 		{ OPTION_CALLBACK, ')', NULL, &opt, NULL, "",
 		  PARSE_OPT_NOARG | PARSE_OPT_NONEG | PARSE_OPT_NODASH,
 		  close_callback },
-		OPT_BOOLEAN('q', "quick", &opt.status_only,
+		OPT_BOOLEAN('q', "quiet", &opt.status_only,
 			    "indicate hit with exit status without output"),
 		OPT_BOOLEAN(0, "all-match", &opt.all_match,
 			"show only matches from files that match all patterns"),
 z:zzz
 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
 # the two files are handled by different calls to an external grep.
 # This depends on MAXARGS in builtin-grep.c being 1024 or less.
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.