From: "René Scharfe" <rene.scharfe@lsrfire.ath.cx>
To: Git Mailing List <git@vger.kernel.org>
Cc: Sverre Rabbelier <srabbelier@gmail.com>,
Junio C Hamano <gitster@pobox.com>
Subject: [PATCH v2 2/2] grep: long context options
Date: Mon, 01 Aug 2011 19:22:52 +0200 [thread overview]
Message-ID: <4E36E0EC.1000508@lsrfire.ath.cx> (raw)
In-Reply-To: <CAGdFq_go0xYy9BZWRDxAFGV95G7V-P9-=7VhsodLd+z-ho09Qw@mail.gmail.com>
Take long option names for -A (--after-context), -B (--before-context)
and -C (--context) from GNU grep and add a similar long option name
for -W (--function-context).
Signed-off-by: Rene Scharfe <rene.scharfe@lsrfire.ath.cx>
---
Documentation/git-grep.txt | 26 +++++++++++++++++---------
builtin/grep.c | 8 ++++----
2 files changed, 21 insertions(+), 13 deletions(-)
diff --git a/Documentation/git-grep.txt b/Documentation/git-grep.txt
index 6cd0c50..af501d2 100644
--- a/Documentation/git-grep.txt
+++ b/Documentation/git-grep.txt
@@ -155,15 +155,6 @@ OPTIONS
Show the filename above the matches in that file instead of
at the start of each shown line.
--[ABC] <context>::
- Show `context` trailing (`A` -- after), or leading (`B`
- -- before), or both (`C` -- context) lines, and place a
- line containing `--` between contiguous groups of
- matches.
-
--<num>::
- A shortcut for specifying `-C<num>`.
-
-p::
--show-function::
Show the preceding line that contains the function name of
@@ -172,7 +163,24 @@ OPTIONS
patch hunk headers (see 'Defining a custom hunk-header' in
linkgit:gitattributes[5]).
+-<num>::
+-C <num>::
+--context <num>::
+ Show <num> leading and trailing lines, and place a line
+ containing `--` between contiguous groups of matches.
+
+-A <num>::
+--after-context <num>::
+ Show <num> trailing lines, and place a line containing
+ `--` between contiguous groups of matches.
+
+-B <num>::
+--before-context <num>::
+ Show <num> leading lines, and place a line containing
+ `--` between contiguous groups of matches.
+
-W::
+--function-context::
Show the surrounding text from the previous line containing a
function name up to the one before the next function name,
effectively showing the whole function in which the match was
diff --git a/builtin/grep.c b/builtin/grep.c
index 1fae662..1851797 100644
--- a/builtin/grep.c
+++ b/builtin/grep.c
@@ -827,18 +827,18 @@ int cmd_grep(int argc, const char **argv, const char *prefix)
OPT_BOOLEAN(0, "heading", &opt.heading,
"show filename only once above matches from same file"),
OPT_GROUP(""),
- OPT_CALLBACK('C', NULL, &opt, "n",
+ OPT_CALLBACK('C', "context", &opt, "n",
"show <n> context lines before and after matches",
context_callback),
- OPT_INTEGER('B', NULL, &opt.pre_context,
+ OPT_INTEGER('B', "before-context", &opt.pre_context,
"show <n> context lines before matches"),
- OPT_INTEGER('A', NULL, &opt.post_context,
+ OPT_INTEGER('A', "after-context", &opt.post_context,
"show <n> context lines after matches"),
OPT_NUMBER_CALLBACK(&opt, "shortcut for -C NUM",
context_callback),
OPT_BOOLEAN('p', "show-function", &opt.funcname,
"show a line with the function name before matches"),
- OPT_BOOLEAN('W', NULL, &opt.funcbody,
+ OPT_BOOLEAN('W', "function-context", &opt.funcbody,
"show the surrounding function"),
OPT_GROUP(""),
OPT_CALLBACK('f', NULL, &opt, "file",
--
1.7.6
next prev parent reply other threads:[~2011-08-01 17:23 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-07-31 15:59 [PATCH] grep: add option to show whole function as context René Scharfe
2011-07-31 17:34 ` Sverre Rabbelier
2011-08-01 15:37 ` René Scharfe
2011-08-01 15:39 ` Sverre Rabbelier
2011-08-01 17:20 ` René Scharfe
2011-08-01 17:20 ` [PATCH v2 1/2] " René Scharfe
2011-08-01 23:17 ` Junio C Hamano
2011-08-02 18:08 ` René Scharfe
2011-08-01 17:22 ` René Scharfe [this message]
2011-08-02 1:01 ` [PATCH v2 2/2] grep: long context options Tait
2011-08-02 17:24 ` René Scharfe
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=4E36E0EC.1000508@lsrfire.ath.cx \
--to=rene.scharfe@lsrfire.ath.cx \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=srabbelier@gmail.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.