X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=builtin-grep.c;h=a5b6719a1af014497399ea6ff4f1a6f3852a0570;hb=bf3c523c3fd641609adcef67dcec47a43a6abd60;hp=d79a6260a4b6f9a467356de117e100cd1a457b23;hpb=24807f9d5bada2475fddd153365c1debfe1309bc;p=git.git diff --git a/builtin-grep.c b/builtin-grep.c index d79a6260a..a5b6719a1 100644 --- a/builtin-grep.c +++ b/builtin-grep.c @@ -433,7 +433,11 @@ static int external_grep(struct grep_opt *opt, const char **paths, int cached) if (opt->color_external && strlen(opt->color_external) > 0) push_arg(opt->color_external); + } else { + unsetenv("GREP_COLOR"); + unsetenv("GREP_COLORS"); } + unsetenv("GREP_OPTIONS"); hit = 0; argc = nr; @@ -788,6 +792,13 @@ int cmd_grep(int argc, const char **argv, const char *prefix) OPT_END() }; + /* + * 'git grep -h', unlike 'git grep -h ', is a request + * to show usage information and exit. + */ + if (argc == 2 && !strcmp(argv[1], "-h")) + usage_with_options(grep_usage, options); + memset(&opt, 0, sizeof(opt)); opt.prefix = prefix; opt.prefix_length = (prefix && *prefix) ? strlen(prefix) : 0;