grep: add option -p/--show-function

The new option -p instructs git grep to print the previous function
definition as a context line, similar to diff -p.  Such context lines
are marked with an equal sign instead of a dash.  This option
complements the existing context options -A, -B, -C.

Function definitions are detected using the same heuristic that diff
uses.  User defined regular expressions are not supported, yet.

Signed-off-by: Rene Scharfe <rene.scharfe@lsrfire.ath.cx>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
René Scharfe
2009-07-02 00:06:34 +02:00
committed by Junio C Hamano
parent 49de321698
commit 2944e4e614
5 changed files with 98 additions and 13 deletions

1
grep.h
View File

@ -79,6 +79,7 @@ struct grep_opt {
int pathname;
int null_following_name;
int color;
int funcname;
char color_match[COLOR_MAXLEN];
const char *color_external;
int regflags;