Re: [RFC PATCH 2/3] grep: prepare grep for submodules
- From
Nguyen Thai Ngoc Duy <pclouds@gmail.com>
- Date
- Sep 30, 2010, 01:10 UTC
- Message-ID
- <AANLkTik3bvJneak9gjG8O1A=LZeivPkFc6MF5_T7nbWo@mail.gmail.com>
- In-Reply-To
- <1285792134-26339-3-git-send-email-judge.packham@gmail.com>
On Thu, Sep 30, 2010 at 6:28 AM, Chris Packham <judge.packham@gmail.com> wrote:
> Add --submodule-prefix option to pass to subprocess grep invocations. The > prefix is then used when outputting the results.
I haven't followed the recursive submodule support in Git lately. But I think --submodule-prefix is unnecessary. I would imagine you need to add --submodule-prefix to a lot more commands as they support recusive submodule search. There is a corner case in Git's prefix setup that we can utilize to avoid the new option.
If you do this at the superproject repo:
$ GIT_DIR=path/to/submodule/.git GIT_WORK_TREE=path/to/submodule git grep blah
I would expect that it shows the result correctly (i.e. all files prefixed by "path/to/submodule"), but it does not right now. If you make that setup work, then you don't need --submodule-prefix, just set GIT_DIR/GIT_WORK_TREE properly and run "git grep".
You can make setup_explicit_git_dir() realize that situation (current working directory outside $GIT_WORK_TREE), then calculate and save the submodule prefix in startup_info struct. Then "git grep" or any commands can just read startup_info to find out the submodule prefix.
-- Duy