grep: optionally recurse into submodules
commit0281e487fd913bd9a32a710f3109ff3002f3e4a9
authorBrandon Williams <bmwill@google.com>
Fri, 16 Dec 2016 19:03:20 +0000 (16 11:03 -0800)
committerJunio C Hamano <gitster@pobox.com>
Thu, 22 Dec 2016 19:47:33 +0000 (22 11:47 -0800)
tree3b5b3bda83044726df670a446bbf6764d2cde6da
parent4538eef564c81c96f2874ccadc54d3c69cc0e19c
grep: optionally recurse into submodules

Allow grep to recognize submodules and recursively search for patterns in
each submodule.  This is done by forking off a process to recursively
call grep on each submodule.  The top level --super-prefix option is
used to pass a path to the submodule which can in turn be used to
prepend to output or in pathspec matching logic.

Recursion only occurs for submodules which have been initialized and
checked out by the parent project.  If a submodule hasn't been
initialized and checked out it is simply skipped.

In order to support the existing multi-threading infrastructure in grep,
output from each child process is captured in a strbuf so that it can be
later printed to the console in an ordered fashion.

To limit the number of theads that are created, each child process has
half the number of threads as its parents (minimum of 1), otherwise we
potentailly have a fork-bomb.

Signed-off-by: Brandon Williams <bmwill@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Documentation/git-grep.txt
builtin/grep.c
git.c
t/t7814-grep-recurse-submodules.sh [new file with mode: 0755]