Subject: Re: 2.46 submodule breakage

From: Patrick Steinhardt <[email-masked]>
Date: Wed, 7 Aug 2024 08:40:10 +0200

On Tue, Aug 06, 2024 at 02:26:35PM -0400, Eric Sunshine wrote:
> On Tue, Aug 6, 2024 at 9:21 AM Jeppe Øland <[email-masked]> wrote:
> > I did a bunch of testing to narrow down the cause:
> >
> > It is not related to the Windows port - all the testing was done in WSL.
> > It only happens when the clone containing submodules is done with
> > --ref-format=reftable.
> > The commit breaking it is: 129cb1b99d hash: drop (mostly) unused
> > `is_empty_{blob,tree}_sha1()` functions
> 
> Cc:'ing Patrick, the author of that change.

Thanks for Cc'ing me, and thanks for the report.

I just wanted to say that I couldn't reproduce, but then spotted that
you said that it only happens when using `--ref-format=reftable` during
the git-clone(1) step. And indeed, that causes the following test to
fail:

    test_expect_success 'recursive pull with different non-default ref format' '
        # Set up the initial structure. This is an upstream repository that has
        # a submodule, as well as a downstream clone of the upstream
        # repository.
        git init submodule &&
        test_commit -C submodule submodule-base &&
        git init upstream &&
        test_commit -C upstream upstream-base &&
        git -C upstream submodule add "file://$(pwd)/submodule" &&
        git -C upstream commit -m "upstream submodule" &&
        git clone --ref-format=reftable --recurse-submodules "file://$(pwd)/upstream" downstream &&

        # Update the submodule.
        test_commit -C submodule submodule-update &&
        git -C upstream/submodule pull &&
        git -C upstream commit -am "update the submodule" &&

        git -C downstream pull --recurse-submodules
    '

The issue here is that the recursive clone causes a mixture of ref
formats: the parent repository uses the "reftable" backend, whereas the
child repository uses "files". In theory, I think Git should be able to
handle a mixture of ref formats like this, but I'm not surprised that it
actually fails in practice. The question is whether this is sensible, or
whether submodules should use the same ref format as their parent.

So it feels like the commit you have bisected this to only unearths this
issue, but isn't the actual root cause.

I'll investigate further and will try to come up with a patch later this
week.

Patrick