grep: long context options

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>

René Scharfe committed Aug 1, 2011 at 19:22 UTC 317f63c21c8eac46813eacf487485445f2f79a6d
2 files changed +21 -13
Documentation/git-grep.txt
+17 -9
@@ -155,15 +155,6 @@ OPTIONS
155 Show the filename above the matches in that file instead of
156 at the start of each shown line.
157
158 --[ABC] <context>::
159 - Show `context` trailing (`A` -- after), or leading (`B`
160 - -- before), or both (`C` -- context) lines, and place a
161 - line containing `--` between contiguous groups of
162 - matches.
163 -
164 --<num>::
165 - A shortcut for specifying `-C<num>`.
166 -
158 -p::
159 --show-function::
160 Show the preceding line that contains the function name of
@@ -172,7 +163,24 @@ OPTIONS
163 patch hunk headers (see 'Defining a custom hunk-header' in
164 linkgit:gitattributes[5]).
165
166 +-<num>::
167 +-C <num>::
168 +--context <num>::
169 + Show <num> leading and trailing lines, and place a line
170 + containing `--` between contiguous groups of matches.
171 +
172 +-A <num>::
173 +--after-context <num>::
174 + Show <num> trailing lines, and place a line containing
175 + `--` between contiguous groups of matches.
176 +
177 +-B <num>::
178 +--before-context <num>::
179 + Show <num> leading lines, and place a line containing
180 + `--` between contiguous groups of matches.
181 +
182 -W::
183 +--function-context::
184 Show the surrounding text from the previous line containing a
185 function name up to the one before the next function name,
186 effectively showing the whole function in which the match was
builtin/grep.c
+4 -4
@@ -827,18 +827,18 @@ int cmd_grep(int argc, const char **argv, const char *prefix)
827 OPT_BOOLEAN(0, "heading", &opt.heading,
828 "show filename only once above matches from same file"),
829 OPT_GROUP(""),
830 - OPT_CALLBACK('C', NULL, &opt, "n",
830 + OPT_CALLBACK('C', "context", &opt, "n",
831 "show <n> context lines before and after matches",
832 context_callback),
833 - OPT_INTEGER('B', NULL, &opt.pre_context,
833 + OPT_INTEGER('B', "before-context", &opt.pre_context,
834 "show <n> context lines before matches"),
835 - OPT_INTEGER('A', NULL, &opt.post_context,
835 + OPT_INTEGER('A', "after-context", &opt.post_context,
836 "show <n> context lines after matches"),
837 OPT_NUMBER_CALLBACK(&opt, "shortcut for -C NUM",
838 context_callback),
839 OPT_BOOLEAN('p', "show-function", &opt.funcname,
840 "show a line with the function name before matches"),
841 - OPT_BOOLEAN('W', NULL, &opt.funcbody,
841 + OPT_BOOLEAN('W', "function-context", &opt.funcbody,
842 "show the surrounding function"),
843 OPT_GROUP(""),
844 OPT_CALLBACK('f', NULL, &opt, "file",