From: "D. Ben Knoble via GitGitGadget" <gitgitgadget@gmail.com>
To: git@vger.kernel.org
Cc: "D. Ben Knoble" <ben.knoble+github@gmail.com>,
"D. Ben Knoble" <ben.knoble+github@gmail.com>
Subject: [PATCH] grep: document negated line-number, column long options
Date: Thu, 16 Jan 2025 22:20:41 +0000 [thread overview]
Message-ID: <pull.1878.git.git.1737066042014.gitgitgadget@gmail.com> (raw)
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
next reply other threads:[~2025-01-16 22:20 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-16 22:20 D. Ben Knoble via GitGitGadget [this message]
2025-01-16 22:54 ` [PATCH] grep: document negated line-number, column long options 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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=pull.1878.git.git.1737066042014.gitgitgadget@gmail.com \
--to=gitgitgadget@gmail.com \
--cc=ben.knoble+github@gmail.com \
--cc=git@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).