Code

Merge branch 'di/fast-import-tagging'
[git.git] / builtin / grep.c
index cccf8da6d2a600154536ea642250699d9356f148..1851797540c17791f03e0d2fb86f5463e4e3816e 100644 (file)
@@ -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);
        }