diff options
author | Junio C Hamano <gitster@pobox.com> | 2011-08-11 11:03:09 -0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2011-08-11 11:03:09 -0700 |
commit | 5fb249aec763205f8d26370a18c5adb167008dd8 (patch) | |
tree | d3fcf60ccad806d032855dcb390992071a7f5dea /builtin | |
parent | 1c1b7eed5c7fc6ca397eab006be67646c9f599d7 (diff) | |
parent | 317f63c21c8eac46813eacf487485445f2f79a6d (diff) | |
download | git-5fb249aec763205f8d26370a18c5adb167008dd8.tar.gz |
Merge branch 'rs/grep-function-context'
* rs/grep-function-context:
grep: long context options
grep: add option to show whole function as context
Diffstat (limited to 'builtin')
-rw-r--r-- | builtin/grep.c | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/builtin/grep.c b/builtin/grep.c index cccf8da6d2..1851797540 100644 --- a/builtin/grep.c +++ b/builtin/grep.c @@ -827,17 +827,19 @@ 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_CALLBACK('C', NULL, &opt, "n", + OPT_CALLBACK('C', "context", &opt, "n", "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"), - 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"), + OPT_BOOLEAN('W', "function-context", &opt.funcbody, + "show the surrounding function"), OPT_GROUP(""), OPT_CALLBACK('f', NULL, &opt, "file", "read patterns from file", file_callback), @@ -980,7 +982,8 @@ int cmd_grep(int argc, const char **argv, const char *prefix) use_threads = 0; if (use_threads) { - if (opt.pre_context || opt.post_context || opt.file_break) + if (opt.pre_context || opt.post_context || opt.file_break || + opt.funcbody) skip_first_line = 1; start_threads(&opt); } |