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

[PATCH 0/3] builtin/grep: fix reading objects from wrong repository

From
Patrick Steinhardt <ps@pks.im>
Date
Oct 30, 2026, 10:21 UTC
Message-ID
<20261030-pks-grep-recurse-submodule-v1-0-d4eb5c87d8fb@pks.im>
Hi,

this small patch series fixes the bug reported in [1], where doing `git grep --recurse-submodules` with nested submodule trees fails to read the trees. The only patch needed here is the first one, the other patches are only belt-and-suspenders as I've been checking whether we use the wrong repository anywhere else.

At the end of this patch series we only use `the_repository` in `cmd_grep()` itself. Ideally we'd adapt "builtin/grep.c" to get rid of `the_repository` altogether, but unfortunately it's a bit on the involved side as we also have to worry about the case where git-grep(1) is executed outside of a repository with "--no-index". So I skipped that refactoring for now.

The patch is based on v2.56.0 so that it can be easily backported.
Thanks!
Patrick
[1]: <CAMtVYEjWd2XwJpXdk3PV2jbNdoOaqS3x+08EMu5byy55RxfRmA@mail.gmail.com>
---
Patrick Steinhardt (3):
      builtin/grep: read submodule trees via their repository
      builtin/grep: read sparse directory trees via passed-in repository
      builtin/grep: read ".gitmodules" via passed-in repository
 builtin/grep.c                     |  6 +++---
 t/t7814-grep-recurse-submodules.sh | 23 +++++++++++++++++++++++
 2 files changed, 26 insertions(+), 3 deletions(-)

--- base-commit: a018953688f1b10bddf91bff8747068f5f4746a4 change-id: 20261030-pks-grep-recurse-submodule-20177cc7794c

Next: Patrick Steinhardt
Message 1 of 10 in “builtin/grep: fix reading objects from wrong repository”
  1. 0/3 builtin/grep: fix reading objects from wrong repositoryPatrick Steinhardt, Oct 30, 2026
  2. 1/3 builtin/grep: read submodule trees via their repositoryPatrick Steinhardt, Oct 30, 2026
  3. Toon ClaesOct 30, 2026
  4. Patrick SteinhardtNov 3, 2026
  5. 2/3 builtin/grep: read sparse directory trees via passed-in repositoryPatrick Steinhardt, Oct 30, 2026
  6. 3/3 builtin/grep: read ".gitmodules" via passed-in repositoryPatrick Steinhardt, Oct 30, 2026
  7. 0/3 builtin/grep: fix reading objects from wrong repositoryPatrick Steinhardt, Nov 3, 2026
  8. 1/3 builtin/grep: read submodule trees via their repositoryPatrick Steinhardt, Nov 3, 2026
  9. 2/3 builtin/grep: read sparse directory trees via passed-in repositoryPatrick Steinhardt, Nov 3, 2026
  10. 3/3 builtin/grep: read ".gitmodules" via passed-in repositoryPatrick Steinhardt, Nov 3, 2026

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.