Re: [RFC PATCH 2/3] grep: prepare grep for submodules
From: Nguyen Thai Ngoc Duy <hidden>
Date: 2016-06-15 22:49:39
On Thu, Sep 30, 2010 at 6:28 AM, Chris Packham [off-list ref] 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