git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] grep: document negated line-number, column long options
@ 2025-01-16 22:20 D. Ben Knoble via GitGitGadget
  2025-01-16 22:54 ` Junio C Hamano
  0 siblings, 1 reply; 9+ messages in thread
From: D. Ben Knoble via GitGitGadget @ 2025-01-16 22:20 UTC (permalink / raw)
  To: git; +Cc: D. Ben Knoble, D. Ben Knoble

From: "D. Ben Knoble" <ben.knoble+github@gmail.com>

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 <ben.knoble+github@gmail.com>
---
    grep: document negated line-number, column long options

Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-1878%2Fbenknoble%2Fdocument-grep-negated-options-v1
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-1878/benknoble/document-grep-negated-options-v1
Pull-Request: https://github.com/git/git/pull/1878

 Documentation/git-grep.txt | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/Documentation/git-grep.txt b/Documentation/git-grep.txt
index 1e6d7b65c84..7ec5ad381db 100644
--- a/Documentation/git-grep.txt
+++ b/Documentation/git-grep.txt
@@ -13,7 +13,7 @@ SYNOPSIS
 	   [-v | --invert-match] [-h|-H] [--full-name]
 	   [-E | --extended-regexp] [-G | --basic-regexp]
 	   [-P | --perl-regexp]
-	   [-F | --fixed-strings] [-n | --line-number] [--column]
+	   [-F | --fixed-strings] [-n | --[no-]line-number] [--[no-]column]
 	   [-l | --files-with-matches] [-L | --files-without-match]
 	   [(-O | --open-files-in-pager) [<pager>]]
 	   [-z | --null]
@@ -157,10 +157,18 @@ providing this option will cause it to die.
 --line-number::
 	Prefix the line number to matching lines.
 
+--no-line-number::
+	Turn off line number prefixes, even when the configuration file or a
+	previous option requests them.
+
 --column::
 	Prefix the 1-indexed byte-offset of the first match from the start of the
 	matching line.
 
+--no-column::
+	Turn off column prefixes, even when the configuration file or a
+	previous option requests them.
+
 -l::
 --files-with-matches::
 --name-only::

base-commit: 757161efcca150a9a96b312d9e780a071e601a03
-- 
gitgitgadget

^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2025-01-21 20:51 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-01-16 22:20 [PATCH] grep: document negated line-number, column long options D. Ben Knoble via GitGitGadget
2025-01-16 22:54 ` Junio C Hamano
2025-01-17  0:29   ` Junio C Hamano
2025-01-17  2:05     ` [PATCH v2] gitcli: document that command line trumps config and env Junio C Hamano
2025-01-17  2:41       ` brian m. carlson
2025-01-17 18:09         ` Junio C Hamano
2025-01-17  3:14     ` [PATCH] grep: document negated line-number, column long options Eric Sunshine
2025-01-19 23:17   ` D. Ben Knoble
2025-01-21 20:51     ` Junio C Hamano

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).