summaryrefslogtreecommitdiff
path: root/builtin/grep.c
diff options
context:
space:
mode:
authorRené Scharfe <l.s.r@web.de>2018-10-01 19:15:57 (GMT)
committerJunio C Hamano <gitster@pobox.com>2018-10-04 04:25:57 (GMT)
commit0a09e5edc281941b77dbf7aa3436781250d16088 (patch)
tree7a40830ed88b1973e36ff2be353987ffe31b83bb /builtin/grep.c
parentfe8321ec057f9231c26c29b364721568e58040f7 (diff)
downloadgit-0a09e5edc281941b77dbf7aa3436781250d16088.zip
git-0a09e5edc281941b77dbf7aa3436781250d16088.tar.gz
git-0a09e5edc281941b77dbf7aa3436781250d16088.tar.bz2
grep: add -r/--[no-]recursive
Recognize -r and --recursive as synonyms for --max-depth=-1 for compatibility with GNU grep; it's still the default for git grep. This also adds --no-recursive as synonym for --max-depth=0 for free, which is welcome for completeness and consistency. Fix the description for --max-depth, while we're at it -- negative values other than -1 actually disable recursion, i.e. they are equivalent to --max-depth=0. Requested-by: Christoph Berg <myon@debian.org> Suggested-by: Junio C Hamano <gitster@pobox.com> Initial-patch-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Signed-off-by: Rene Scharfe <l.s.r@web.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin/grep.c')
-rw-r--r--builtin/grep.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/builtin/grep.c b/builtin/grep.c
index 601f801..f6e127f 100644
--- a/builtin/grep.c
+++ b/builtin/grep.c
@@ -811,6 +811,8 @@ int cmd_grep(int argc, const char **argv, const char *prefix)
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 },