git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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
Previous: Chris PackhamNext: Chris Packham
Message 7 of 22 in “grep: submodule support”
  1. 0/3 grep: submodule supportChris Packham, Sep 29, 2010
  2. 1/3 add test for git grep --recursiveChris Packham, Sep 29, 2010
  3. Ævar Arnfjörð BjarmasonSep 29, 2010
  4. Chris PackhamSep 29, 2010
  5. Kevin BallardSep 29, 2010
  6. 2/3 grep: prepare grep for submodulesChris Packham, Sep 29, 2010
  7. Nguyen Thai Ngoc DuySep 30, 2010
  8. Chris PackhamSep 30, 2010
  9. Nguyen Thai Ngoc DuyOct 1, 2010
  10. Chris PackhamOct 1, 2010
  11. 3/3 grep: add support for grepping in submodulesChris Packham, Sep 29, 2010
  12. Jens LehmannSep 29, 2010
  13. Junio C HamanoSep 29, 2010
  14. Chris PackhamSep 29, 2010
  15. Jens LehmannSep 30, 2010
  16. Johannes SixtSep 30, 2010
  17. Jens LehmannSep 30, 2010
  18. Chris PackhamSep 29, 2010
  19. Jens LehmannSep 30, 2010
  20. Chris PackhamSep 30, 2010
  21. Heiko VoigtSep 30, 2010
  22. Jens LehmannSep 30, 2010

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.