Re: [PATCH v9 2/3] introduce submodule.hasSuperproject record
- From
Emily Shaffer <emilyshaffer@google.com>
- Date
- Mar 15, 2022, 20:56 UTC
- Message-ID
- <YjD9bgmy9ArubMoG@google.com>
- In-Reply-To
- <YjD7mWPEnm/0Evy1@google.com>
On Tue, Mar 15, 2022 at 01:48:25PM -0700, Emily Shaffer wrote:
Show 13 quoted lines
> > +static void set_hassuperproject(const char *sm_path)
> > +{
> > + struct repository subrepo;
> > + char *cfg_file;
> > +
> > + if (repo_submodule_init(&subrepo, the_repository, sm_path, null_oid()))
> > + die(_("could not get a repository handle for submodule '%s'"), sm_path);
>
> Isn't the repo_submodule_init() fairly expensive? I think this is doing
> a whole repo_init() call we would not otherwise be doing.... Is it good
> enough to generate the config from sm_path, by using
> strbuf_repo_worktree_path(), and simply be tolerant of the failure if
> <sm-gitdir>/config doesn't exist?Ah, I was misreading the implementation of repo_submodule_init() and I see now that won't work. I guess it is fine to just invoke repo_submodule_init() then, unless someone has another idea.