From: Junio C Hamano Date: Thu, 11 Aug 2011 18:03:09 +0000 (-0700) Subject: Merge branch 'rs/grep-function-context' X-Git-Tag: v1.7.7-rc0~39 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/5fb249aec763205f8d26370a18c5adb167008dd8?hp=-c Merge branch 'rs/grep-function-context' * rs/grep-function-context: grep: long context options grep: add option to show whole function as context --- 5fb249aec763205f8d26370a18c5adb167008dd8 diff --combined Documentation/git-grep.txt index 062711139c,af501d2424..e44a4988b7 --- a/Documentation/git-grep.txt +++ b/Documentation/git-grep.txt @@@ -155,15 -155,6 +155,6 @@@ OPTION 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,6 -163,29 +163,29 @@@ 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 + found. + -f :: Read patterns from , one per line. @@@ -215,15 -229,15 +229,15 @@@ Examples -------- -git grep {apostrophe}time_t{apostrophe} \-- {apostrophe}*.[ch]{apostrophe}:: +`git grep {apostrophe}time_t{apostrophe} \-- {apostrophe}*.[ch]{apostrophe}`:: Looks for `time_t` in all tracked .c and .h files in the working directory and its subdirectories. -git grep -e {apostrophe}#define{apostrophe} --and \( -e MAX_PATH -e PATH_MAX \):: +`git grep -e {apostrophe}#define{apostrophe} --and \( -e MAX_PATH -e PATH_MAX \)`:: Looks for a line that has `#define` and either `MAX_PATH` or `PATH_MAX`. -git grep --all-match -e NODE -e Unexpected:: +`git grep --all-match -e NODE -e Unexpected`:: Looks for a line that has `NODE` or `Unexpected` in files that have lines that match both.