Re: [BUG] grep --recurse-submodules <tree> dies on a directory inside a submodule
Hi,
On Thu, Oct 29, 2026 at 07:52:07PM +0000, Root wrote:
Show 41 quoted lines
> Hi,
>
> Since Git 2.56.0, "git grep --recurse-submodules <pattern> <tree>"
> dies when it reaches a directory inside a submodule:
> fatal: unable to read tree (<id of that directory's tree>)
>
> The working-tree form ("git grep --recurse-submodules <pattern>") is
> not affected, and neither is a submodule with no directories. Our CI
> passed the same case on 2.55.0.
>
> What did you do before the bug happened? (Steps to reproduce your issue)
>
> #!/bin/sh
> set -e
> work=$(mktemp -d)
> cd "$work"
>
> git init -q sub
> mkdir sub/dir
> echo hello >sub/top
> echo hello >sub/dir/nested
> git -C sub add top dir/nested
> git -C sub -c user.name=t -c user.email=t@t commit -qm sub
>
> git init -q super
> git -C super -c protocol.file.allow=always \
> submodule --quiet add "$work/sub" sub
> git -C super -c user.name=t -c user.email=t@t commit -qm super
>
> git -C super grep --recurse-submodules -e hello HEAD
>
> What did you expect to happen? (Expected behavior)
>
> HEAD:sub/dir/nested:hello
> HEAD:sub/top:hello
>
> What happened instead? (Actual behavior)
>
> fatal: unable to read tree (935cff11a11f8734cf4e0d40955d1e0e5c12038e)
>
> with exit status 128. The id is that of the tree of sub/dir.indeed, thanks for the report. I've sent patches to fix this via [1].
Thanks!
Patrick
[1]: <20261030-pks-grep-recurse-submodule-v1-0-d4eb5c87d8fb@pks.im>