From: Junio C Hamano Date: Fri, 19 Oct 2018 04:34:05 +0000 (+0900) Subject: Merge branch 'rs/grep-no-recursive' X-Git-Tag: v2.20.0-rc0~155 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/9822b8f10d2c255c3bda81aa800fa056549f034a?ds=inline;hp=-c Merge branch 'rs/grep-no-recursive' Unlike "grep", "git grep" by default recurses to the whole tree. The command learned "git grep --recursive" option, so that "git grep --no-recursive" can serve as a synonym to setting the max-depth to 0. * rs/grep-no-recursive: grep: add -r/--[no-]recursive --- 9822b8f10d2c255c3bda81aa800fa056549f034a diff --combined builtin/grep.c index 0c3527242e,f6e127f0bc..d8508ddf79 --- a/builtin/grep.c +++ b/builtin/grep.c @@@ -103,8 -103,7 +103,8 @@@ static void add_work(struct grep_opt *o todo[todo_end].source = *gs; if (opt->binary != GREP_BINARY_TEXT) - grep_source_load_driver(&todo[todo_end].source); + grep_source_load_driver(&todo[todo_end].source, + opt->repo->index); todo[todo_end].done = 0; strbuf_reset(&todo[todo_end].out); todo_end = (todo_end + 1) % ARRAY_SIZE(todo); @@@ -812,6 -811,8 +812,8 @@@ int cmd_grep(int argc, const char **arg GREP_BINARY_NOMATCH), OPT_BOOL(0, "textconv", &opt.allow_textconv, N_("process binary files with textconv filters")), + OPT_SET_INT('r', "recursive", &opt.max_depth, + N_("search in subdirectories (default)"), -1), { OPTION_INTEGER, 0, "max-depth", &opt.max_depth, N_("depth"), N_("descend at most levels"), PARSE_OPT_NONEG, NULL, 1 }, @@@ -905,9 -906,9 +907,9 @@@ OPT_END() }; - init_grep_defaults(); + init_grep_defaults(the_repository); git_config(grep_cmd_config, NULL); - grep_init(&opt, prefix); + grep_init(&opt, the_repository, prefix); /* * If there is no -- then the paths must exist in the working