зеркало из https://github.com/microsoft/git.git
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
This commit is contained in:
Коммит
9822b8f10d
|
@ -18,7 +18,7 @@ SYNOPSIS
|
||||||
[(-O | --open-files-in-pager) [<pager>]]
|
[(-O | --open-files-in-pager) [<pager>]]
|
||||||
[-z | --null]
|
[-z | --null]
|
||||||
[ -o | --only-matching ] [-c | --count] [--all-match] [-q | --quiet]
|
[ -o | --only-matching ] [-c | --count] [--all-match] [-q | --quiet]
|
||||||
[--max-depth <depth>]
|
[--max-depth <depth>] [--[no-]recursive]
|
||||||
[--color[=<when>] | --no-color]
|
[--color[=<when>] | --no-color]
|
||||||
[--break] [--heading] [-p | --show-function]
|
[--break] [--heading] [-p | --show-function]
|
||||||
[-A <post-context>] [-B <pre-context>] [-C <context>]
|
[-A <post-context>] [-B <pre-context>] [-C <context>]
|
||||||
|
@ -119,11 +119,18 @@ OPTIONS
|
||||||
|
|
||||||
--max-depth <depth>::
|
--max-depth <depth>::
|
||||||
For each <pathspec> given on command line, descend at most <depth>
|
For each <pathspec> given on command line, descend at most <depth>
|
||||||
levels of directories. A negative value means no limit.
|
levels of directories. A value of -1 means no limit.
|
||||||
This option is ignored if <pathspec> contains active wildcards.
|
This option is ignored if <pathspec> contains active wildcards.
|
||||||
In other words if "a*" matches a directory named "a*",
|
In other words if "a*" matches a directory named "a*",
|
||||||
"*" is matched literally so --max-depth is still effective.
|
"*" is matched literally so --max-depth is still effective.
|
||||||
|
|
||||||
|
-r::
|
||||||
|
--recursive::
|
||||||
|
Same as `--max-depth=-1`; this is the default.
|
||||||
|
|
||||||
|
--no-recursive::
|
||||||
|
Same as `--max-depth=0`.
|
||||||
|
|
||||||
-w::
|
-w::
|
||||||
--word-regexp::
|
--word-regexp::
|
||||||
Match the pattern only at word boundary (either begin at the
|
Match the pattern only at word boundary (either begin at the
|
||||||
|
|
|
@ -812,6 +812,8 @@ int cmd_grep(int argc, const char **argv, const char *prefix)
|
||||||
GREP_BINARY_NOMATCH),
|
GREP_BINARY_NOMATCH),
|
||||||
OPT_BOOL(0, "textconv", &opt.allow_textconv,
|
OPT_BOOL(0, "textconv", &opt.allow_textconv,
|
||||||
N_("process binary files with textconv filters")),
|
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"),
|
{ OPTION_INTEGER, 0, "max-depth", &opt.max_depth, N_("depth"),
|
||||||
N_("descend at most <depth> levels"), PARSE_OPT_NONEG,
|
N_("descend at most <depth> levels"), PARSE_OPT_NONEG,
|
||||||
NULL, 1 },
|
NULL, 1 },
|
||||||
|
|
|
@ -309,6 +309,8 @@ do
|
||||||
echo ${HC}v:1:vvv
|
echo ${HC}v:1:vvv
|
||||||
} >expected &&
|
} >expected &&
|
||||||
git grep --max-depth -1 -n -e vvv $H >actual &&
|
git grep --max-depth -1 -n -e vvv $H >actual &&
|
||||||
|
test_cmp expected actual &&
|
||||||
|
git grep --recursive -n -e vvv $H >actual &&
|
||||||
test_cmp expected actual
|
test_cmp expected actual
|
||||||
'
|
'
|
||||||
|
|
||||||
|
@ -317,6 +319,8 @@ do
|
||||||
echo ${HC}v:1:vvv
|
echo ${HC}v:1:vvv
|
||||||
} >expected &&
|
} >expected &&
|
||||||
git grep --max-depth 0 -n -e vvv $H >actual &&
|
git grep --max-depth 0 -n -e vvv $H >actual &&
|
||||||
|
test_cmp expected actual &&
|
||||||
|
git grep --no-recursive -n -e vvv $H >actual &&
|
||||||
test_cmp expected actual
|
test_cmp expected actual
|
||||||
'
|
'
|
||||||
|
|
||||||
|
@ -327,6 +331,8 @@ do
|
||||||
echo ${HC}v:1:vvv
|
echo ${HC}v:1:vvv
|
||||||
} >expected &&
|
} >expected &&
|
||||||
git grep --max-depth 0 -n -e vvv $H -- "*" >actual &&
|
git grep --max-depth 0 -n -e vvv $H -- "*" >actual &&
|
||||||
|
test_cmp expected actual &&
|
||||||
|
git grep --no-recursive -n -e vvv $H -- "*" >actual &&
|
||||||
test_cmp expected actual
|
test_cmp expected actual
|
||||||
'
|
'
|
||||||
|
|
||||||
|
@ -344,6 +350,8 @@ do
|
||||||
echo ${HC}t/v:1:vvv
|
echo ${HC}t/v:1:vvv
|
||||||
} >expected &&
|
} >expected &&
|
||||||
git grep --max-depth 0 -n -e vvv $H -- t >actual &&
|
git grep --max-depth 0 -n -e vvv $H -- t >actual &&
|
||||||
|
test_cmp expected actual &&
|
||||||
|
git grep --no-recursive -n -e vvv $H -- t >actual &&
|
||||||
test_cmp expected actual
|
test_cmp expected actual
|
||||||
'
|
'
|
||||||
|
|
||||||
|
@ -353,6 +361,8 @@ do
|
||||||
echo ${HC}v:1:vvv
|
echo ${HC}v:1:vvv
|
||||||
} >expected &&
|
} >expected &&
|
||||||
git grep --max-depth 0 -n -e vvv $H -- . t >actual &&
|
git grep --max-depth 0 -n -e vvv $H -- . t >actual &&
|
||||||
|
test_cmp expected actual &&
|
||||||
|
git grep --no-recursive -n -e vvv $H -- . t >actual &&
|
||||||
test_cmp expected actual
|
test_cmp expected actual
|
||||||
'
|
'
|
||||||
|
|
||||||
|
@ -362,6 +372,8 @@ do
|
||||||
echo ${HC}v:1:vvv
|
echo ${HC}v:1:vvv
|
||||||
} >expected &&
|
} >expected &&
|
||||||
git grep --max-depth 0 -n -e vvv $H -- t . >actual &&
|
git grep --max-depth 0 -n -e vvv $H -- t . >actual &&
|
||||||
|
test_cmp expected actual &&
|
||||||
|
git grep --no-recursive -n -e vvv $H -- t . >actual &&
|
||||||
test_cmp expected actual
|
test_cmp expected actual
|
||||||
'
|
'
|
||||||
test_expect_success "grep $L with grep.extendedRegexp=false" '
|
test_expect_success "grep $L with grep.extendedRegexp=false" '
|
||||||
|
|
Загрузка…
Ссылка в новой задаче