Subject: Re: 2.46 submodule breakage

From: Junio C Hamano <[email-masked]>
Date: Wed, 07 Aug 2024 09:09:59 -0700

Patrick Steinhardt <[email-masked]> writes:

> For the record, the fix is as simple as the below diff. We indeed end up
> initializing submodule ref stores with the parent ref storage format,
> not with the one of the subrepo. I'll spend some more time though to
> check whether other commands are impacted, as well, and write some more
> tests.

I think allowing separate ref format in submodules is a very
sensible thing to do.  The containing superproject should not even
have to know what ref backend is in use in the submodule, unlike the
object format used there, which it has to know in order to store the
name of commit objects in its tree entries as gitlinks.

And the preimage of this particular change does look wrong to
blindly reuse the format used in the superproject.

Thanks.

> diff --git a/refs.c b/refs.c
> index 915aeb4d1d..e4b1f4f8b1 100644
> --- a/refs.c
> +++ b/refs.c
> @@ -2011,7 +2011,7 @@ struct ref_store *repo_get_submodule_ref_store(struct repository *repo,
>         free(subrepo);
>         goto done;
>     }
> -	refs = ref_store_init(subrepo, the_repository->ref_storage_format,
> +	refs = ref_store_init(subrepo, subrepo->ref_storage_format,
>                   submodule_sb.buf,
>                   REF_STORE_READ | REF_STORE_ODB);
>     register_ref_store_map(&repo->submodule_ref_stores, "submodule",