@matheusbsbs / matheus-bagliano / commits / 3ac4440801
Fork 0

grep documentation: clarify what files match

Clarify that git-grep(1) searches only tracked files, and that each <pathspec> is a pathspec, as in any other ordinary git commands. Add an example to show a simple use case for searching all .c and .h files in the current directory and below. Signed-off-by: Mark Lodato <lodatom@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Mark Lodato committed Feb 15, 2010 at 19:25 UTC 3ac4440801905d11de3ba585c2fe306311db6c45
1 file changed +12 -5
Documentation/git-grep.txt
+12 -5
@@ -22,12 +22,12 @@ SYNOPSIS
22 [-A <post-context>] [-B <pre-context>] [-C <context>]
23 [-f <file>] [-e] <pattern>
24 [--and|--or|--not|(|)|-e <pattern>...] [<tree>...]
25 - [--] [<path>...]
25 + [--] [<pathspec>...]
26
27 DESCRIPTION
28 -----------
29 -Look for specified patterns in the working tree files, blobs
30 -registered in the index file, or given tree objects.
29 +Look for specified patterns in the tracked files in the work tree, blobs
30 +registered in the index file, or blobs in given tree objects.
31
32
33 OPTIONS
@@ -49,7 +49,7 @@ OPTIONS
49 Don't match the pattern in binary files.
50
51 --max-depth <depth>::
52 - For each pathspec given on command line, descend at most <depth>
52 + For each <pathspec> given on command line, descend at most <depth>
53 levels of directories. A negative value means no limit.
54
55 -w::
@@ -163,12 +163,19 @@ OPTIONS
163
164 \--::
165 Signals the end of options; the rest of the parameters
166 - are <path> limiters.
166 + are <pathspec> limiters.
167
168 +<pathspec>...::
169 + If given, limit the search to paths matching at least one pattern.
170 + Both leading paths match and glob(7) patterns are supported.
171
172 Example
173 -------
174
175 +git grep 'time_t' -- '*.[ch]'::
176 + Looks for `time_t` in all tracked .c and .h files in the working
177 + directory and its subdirectories.
178 +
179 git grep -e \'#define\' --and \( -e MAX_PATH -e PATH_MAX \)::
180 Looks for a line that has `#define` and either `MAX_PATH` or
181 `PATH_MAX`.