зеркало из https://github.com/microsoft/git.git
grep: ignore --recurse-submodules if --no-index is given
Since grep learned to recurse into submodules in 0281e487fd
(grep: optionally recurse into submodules, 2016-12-16),
using --recurse-submodules along with --no-index makes Git
die().
This is unfortunate because if submodule.recurse is set in a user's
~/.gitconfig, invoking `git grep --no-index` either inside or outside
a Git repository results in
fatal: option not supported with --recurse-submodules
Let's allow using these options together, so that setting submodule.recurse
globally does not prevent using `git grep --no-index`.
Using `--recurse-submodules` should not have any effect if `--no-index`
is used inside a repository, as Git will recurse into the checked out
submodule directories just like into regular directories.
Helped-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: Philippe Blain <levraiphilippeblain@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Родитель
a0ba80001a
Коммит
c56c48dd07
|
@ -96,7 +96,8 @@ OPTIONS
|
||||||
Recursively search in each submodule that has been initialized and
|
Recursively search in each submodule that has been initialized and
|
||||||
checked out in the repository. When used in combination with the
|
checked out in the repository. When used in combination with the
|
||||||
<tree> option the prefix of all submodule output will be the name of
|
<tree> option the prefix of all submodule output will be the name of
|
||||||
the parent project's <tree> object.
|
the parent project's <tree> object. This option has no effect
|
||||||
|
if `--no-index` is given.
|
||||||
|
|
||||||
-a::
|
-a::
|
||||||
--text::
|
--text::
|
||||||
|
|
|
@ -958,6 +958,9 @@ int cmd_grep(int argc, const char **argv, const char *prefix)
|
||||||
/* die the same way as if we did it at the beginning */
|
/* die the same way as if we did it at the beginning */
|
||||||
setup_git_directory();
|
setup_git_directory();
|
||||||
}
|
}
|
||||||
|
/* Ignore --recurse-submodules if --no-index is given or implied */
|
||||||
|
if (!use_index)
|
||||||
|
recurse_submodules = 0;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* skip a -- separator; we know it cannot be
|
* skip a -- separator; we know it cannot be
|
||||||
|
@ -1115,8 +1118,8 @@ int cmd_grep(int argc, const char **argv, const char *prefix)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (recurse_submodules && (!use_index || untracked))
|
if (recurse_submodules && untracked)
|
||||||
die(_("option not supported with --recurse-submodules"));
|
die(_("--untracked not supported with --recurse-submodules"));
|
||||||
|
|
||||||
if (!show_in_pager && !opt.status_only)
|
if (!show_in_pager && !opt.status_only)
|
||||||
setup_pager();
|
setup_pager();
|
||||||
|
|
|
@ -345,7 +345,16 @@ test_incompatible_with_recurse_submodules ()
|
||||||
}
|
}
|
||||||
|
|
||||||
test_incompatible_with_recurse_submodules --untracked
|
test_incompatible_with_recurse_submodules --untracked
|
||||||
test_incompatible_with_recurse_submodules --no-index
|
|
||||||
|
test_expect_success 'grep --recurse-submodules --no-index ignores --recurse-submodules' '
|
||||||
|
git grep --recurse-submodules --no-index -e "^(.|.)[\d]" >actual &&
|
||||||
|
cat >expect <<-\EOF &&
|
||||||
|
a:(1|2)d(3|4)
|
||||||
|
submodule/a:(1|2)d(3|4)
|
||||||
|
submodule/sub/a:(1|2)d(3|4)
|
||||||
|
EOF
|
||||||
|
test_cmp expect actual
|
||||||
|
'
|
||||||
|
|
||||||
test_expect_success 'grep --recurse-submodules should pass the pattern type along' '
|
test_expect_success 'grep --recurse-submodules should pass the pattern type along' '
|
||||||
# Fixed
|
# Fixed
|
||||||
|
|
Загрузка…
Ссылка в новой задаче