From ba8ea7496f2b95c49fccb72ed6b332afbd865e7b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Scharfe?= Date: Mon, 1 Aug 2011 19:20:53 +0200 Subject: grep: add option to show whole function as context Add a new option, -W, to show the whole surrounding function of a match. It uses the same regular expressions as -p and diff to find the beginning of sections. Currently it will not display comments in front of a function, but those that are following one. Despite this shortcoming it is already useful, e.g. to simply see a more complete applicable context or to extract whole functions. Signed-off-by: Rene Scharfe Signed-off-by: Junio C Hamano --- Documentation/git-grep.txt | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'Documentation/git-grep.txt') diff --git a/Documentation/git-grep.txt b/Documentation/git-grep.txt index 07b3c6a086..6cd0c503f6 100644 --- a/Documentation/git-grep.txt +++ b/Documentation/git-grep.txt @@ -172,6 +172,12 @@ OPTIONS patch hunk headers (see 'Defining a custom hunk-header' in linkgit:gitattributes[5]). +-W:: + 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 + found. + -f :: Read patterns from , one per line. -- cgit v1.2.1 From 317f63c21c8eac46813eacf487485445f2f79a6d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Scharfe?= Date: Mon, 1 Aug 2011 19:22:52 +0200 Subject: 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 Signed-off-by: Junio C Hamano --- Documentation/git-grep.txt | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) (limited to 'Documentation/git-grep.txt') diff --git a/Documentation/git-grep.txt b/Documentation/git-grep.txt index 6cd0c503f6..af501d2424 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] :: - Show `context` trailing (`A` -- after), or leading (`B` - -- before), or both (`C` -- context) lines, and place a - line containing `--` between contiguous groups of - matches. - --:: - A shortcut for specifying `-C`. - -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]). +-:: +-C :: +--context :: + Show leading and trailing lines, and place a line + containing `--` between contiguous groups of matches. + +-A :: +--after-context :: + Show trailing lines, and place a line containing + `--` between contiguous groups of matches. + +-B :: +--before-context :: + Show 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 -- cgit v1.2.1