From: Mark Lodato Date: Tue, 16 Feb 2010 00:25:40 GMT Subject: [PATCHv2] grep documentation: clarify what files match Message-ID: <1266279940-13251-1-git-send-email-lodatom@gmail.com> In-Reply-To: <7vvddz5l1z.fsf@alter.siamese.dyndns.org> Clarify that git-grep(1) searches only tracked files, and that each is a glob, as in git-add(1). Add an example to show a simple use case for searching all .c and .h files. The meta-variable should be changed to an official term for a path glob, and the description for this should be in git(1), not git-add(1). However, we don't yet have such an official term, so just use and reference git-add(1) for now. Signed-off-by: Mark Lodato --- Documentation/git-grep.txt | 13 ++++++++++--- 1 files changed, 10 insertions(+), 3 deletions(-) diff --git a/Documentation/git-grep.txt b/Documentation/git-grep.txt index e019e76..7f24032 100644 --- a/Documentation/git-grep.txt +++ b/Documentation/git-grep.txt @@ -26,8 +26,8 @@ SYNOPSIS DESCRIPTION ----------- -Look for specified patterns in the working tree files, blobs -registered in the index file, or given tree objects. +Look for specified patterns in the tracked files in the working tree, blobs +registered in the index file, or blobs in given tree objects. OPTIONS @@ -49,7 +49,7 @@ OPTIONS Don't match the pattern in binary files. --max-depth :: - For each pathspec given on command line, descend at most + For each given on command line, descend at most levels of directories. A negative value means no limit. -w:: @@ -170,10 +170,17 @@ OPTIONS Signals the end of options; the rest of the parameters are limiters. +...:: + If given, limit the search to paths matching at least one pattern. + Each pattern is the same as of linkgit:git-add[1]. Example ------- +git grep 'time_t' -- '*.[ch]':: + Looks for `time_t` in all tracked .c and .h files in the working + directory. + git grep -e \'#define\' --and \( -e MAX_PATH -e PATH_MAX \):: Looks for a line that has `#define` and either `MAX_PATH` or `PATH_MAX`. -- 1.7.0