Merge branch 'rs/grep-no-recursive'
authorJunio C Hamano <gitster@pobox.com>
Fri, 19 Oct 2018 04:34:05 +0000 (13:34 +0900)
committerJunio C Hamano <gitster@pobox.com>
Fri, 19 Oct 2018 04:34:06 +0000 (13:34 +0900)
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

1  2 
builtin/grep.c
diff --combined builtin/grep.c
index 0c3527242eb052810b4d6487954d241f16d4860d,f6e127f0bca3b9569aa0bc29bbc70b3a91a78651..d8508ddf792dd22dc0c8c283df29e5e6d9dacbf7
@@@ -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 <depth> levels"), PARSE_OPT_NONEG,
                        NULL, 1 },
                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