Skip to content

Commit 290e9be

Browse files
committed
grep: document negated line-number, column long options
I set grep.lineNumber and grep.column on in my user .gitconfig; sometimes, when I script over the results from `git grep`, I want no prefixes, only a filename prefix, or only the matched text. I usually comment out the relevant config sections or use `git -c` to tweak them for a single run---why? Because `git help grep` doesn't mention they can be disabled any other way! Intending to add the ability to negate these options, I reviewed builtin/grep.c and learned that OPT_BOOL already provides this feature. Document it for future readers. Borrow "configuration file" language from `--no-color`, since that's my motivating use case. Signed-off-by: D. Ben Knoble <[email protected]>
1 parent 757161e commit 290e9be

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

Documentation/git-grep.txt

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ SYNOPSIS
1313
[-v | --invert-match] [-h|-H] [--full-name]
1414
[-E | --extended-regexp] [-G | --basic-regexp]
1515
[-P | --perl-regexp]
16-
[-F | --fixed-strings] [-n | --line-number] [--column]
16+
[-F | --fixed-strings] [-n | --[no-]line-number] [--[no-]column]
1717
[-l | --files-with-matches] [-L | --files-without-match]
1818
[(-O | --open-files-in-pager) [<pager>]]
1919
[-z | --null]
@@ -157,10 +157,18 @@ providing this option will cause it to die.
157157
--line-number::
158158
Prefix the line number to matching lines.
159159

160+
--no-line-number::
161+
Turn off line number prefixes, even when the configuration file or a
162+
previous option requests them.
163+
160164
--column::
161165
Prefix the 1-indexed byte-offset of the first match from the start of the
162166
matching line.
163167

168+
--no-column::
169+
Turn off column prefixes, even when the configuration file or a
170+
previous option requests them.
171+
164172
-l::
165173
--files-with-matches::
166174
--name-only::

0 commit comments

Comments
 (0)