git-grep: document --and, --or, --not, ( and )
[git/jrn.git] / Documentation / git-grep.txt
blobdc7683383c3b4dc4c6bede834155ae56132aafc3
1 git-grep(1)
2 ===========
4 NAME
5 ----
6 git-grep - Print lines matching a pattern
9 SYNOPSIS
10 --------
11 [verse]
12 'git-grep' [--cached]
13            [-a | --text] [-I] [-i | --ignore-case] [-w | --word-regexp]
14            [-v | --invert-match]
15            [-E | --extended-regexp] [-G | --basic-regexp] [-F | --fixed-strings]
16            [-n] [-l | --files-with-matches] [-L | --files-without-match]
17            [-c | --count]
18            [-A <post-context>] [-B <pre-context>] [-C <context>]
19            [-f <file>] [-e] <pattern> [--and|--or|--not|(|)|-e <pattern>...]
20            [<tree>...]
21            [--] [<path>...]
23 DESCRIPTION
24 -----------
25 Look for specified patterns in the working tree files, blobs
26 registered in the index file, or given tree objects.
29 OPTIONS
30 -------
31 --cached::
32         Instead of searching in the working tree files, check
33         the blobs registered in the index file.
35 -a | --text::
36         Process binary files as if they were text.
38 -i | --ignore-case::
39         Ignore case differences between the patterns and the
40         files.
42 -w | --word-regexp::
43         Match the pattern only at word boundary (either begin at the
44         beginning of a line, or preceded by a non-word character; end at
45         the end of a line or followed by a non-word character).
47 -v | --invert-match::
48         Select non-matching lines.
50 -E | --extended-regexp | -G | --basic-regexp::
51         Use POSIX extended/basic regexp for patterns.  Default
52         is to use basic regexp.
54 -n::
55         Prefix the line number to matching lines.
57 -l | --files-with-matches | -L | --files-without-match::
58         Instead of showing every matched line, show only the
59         names of files that contain (or do not contain) matches.
61 -c | --count::
62         Instead of showing every matched line, show the number of
63         lines that match.
65 -[ABC] <context>::
66         Show `context` trailing (`A` -- after), or leading (`B`
67         -- before), or both (`C` -- context) lines, and place a
68         line containing `--` between contiguous groups of
69         matches.
71 -f <file>::
72         Read patterns from <file>, one per line.
74 -e::
75         The next parameter is the pattern. This option has to be
76         used for patterns starting with - and should be used in
77         scripts passing user input to grep.  Multiple patterns are
78         combined by 'or'.
80 --and | --or | --not | ( | )::
81         Specify how multiple patterns are combined using boolean
82         expressions.  `--or` is the default operator.  `--and` has
83         higher precedence than `--or`.  `-e` has to be used for all
84         patterns.
86 `<tree>...`::
87         Search blobs in the trees for specified patterns.
89 \--::
90         Signals the end of options; the rest of the parameters
91         are <path> limiters.
94 Example
95 -------
97 git grep -e \'#define\' --and \( -e MAX_PATH -e PATH_MAX \)::
98         Looks for a line that has `#define` and either `MAX_PATH` or
99         `PATH_MAX`.
101 Author
102 ------
103 Originally written by Linus Torvalds <torvalds@osdl.org>, later
104 revamped by Junio C Hamano.
107 Documentation
108 --------------
109 Documentation by Junio C Hamano and the git-list <git@vger.kernel.org>.
113 Part of the gitlink:git[7] suite