grep: long context options
authorRené Scharfe <rene.scharfe@lsrfire.ath.cx>
Mon, 1 Aug 2011 17:22:52 +0000 (19:22 +0200)
committerJunio C Hamano <gitster@pobox.com>
Mon, 1 Aug 2011 23:11:50 +0000 (16:11 -0700)
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>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Documentation/git-grep.txt
builtin/grep.c
index 6cd0c503f63c2e2ffe49ef5ffc7e64677ae721cd..af501d2424249e0dd0e6c706a84b8de55b7738b9 100644 (file)
@@ -155,15 +155,6 @@ OPTIONS
        Show the filename above the matches in that file instead of
        at the start of each shown line.
 
        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
 -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]).
 
        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::
 -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
        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
index 1fae66262f25fb0d3837ceffad8db44555c5b88b..1851797540c17791f03e0d2fb86f5463e4e3816e 100644 (file)
@@ -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_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),
                        "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"),
                        "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"),
                        "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",
                        "show the surrounding function"),
                OPT_GROUP(""),
                OPT_CALLBACK('f', NULL, &opt, "file",