Re: [PATCH 18/19] submodule: use submodule repos for object lookup
- From
Stefan Beller <sbeller@google.com>
- Date
- Nov 1, 2018, 19:13 UTC
- Message-ID
- <CAGZ79kanW632k=LHzT9RhmDMSpCTK8K2sPswsF7H0RRC1aLqVQ@mail.gmail.com>
- In-Reply-To
- <ab0f5b37-b4f1-3efc-b30f-f3b34f2a11cb@gmail.com>
On Wed, Oct 31, 2018 at 6:38 AM Derrick Stolee <stolee@gmail.com> wrote:
Show 40 quoted lines
>
> On 10/16/2018 7:35 PM, Stefan Beller wrote:
> > @@ -482,14 +483,46 @@ void prepare_submodule_repo_env(struct argv_array *out)
> > DEFAULT_GIT_DIR_ENVIRONMENT);
> > }
> >
> > -/* Helper function to display the submodule header line prior to the full
> > - * summary output. If it can locate the submodule objects directory it will
> > - * attempt to lookup both the left and right commits and put them into the
> > - * left and right pointers.
> > +/*
> > + * Initialize 'out' based on the provided submodule path.
> > + *
> > + * Unlike repo_submodule_init, this tolerates submodules not present
> > + * in .gitmodules. This function exists only to preserve historical behavior,
> > + *
> > + * Returns 0 on success, -1 when the submodule is not present.
> > + */
> > +static int open_submodule(struct repository *out, const char *path)
> > +{
> > + struct strbuf sb = STRBUF_INIT;
> > +
> > + if (submodule_to_gitdir(&sb, path) || repo_init(out, sb.buf, NULL)) {
> > + strbuf_release(&sb);
> > + return -1;
> > + }
> > +
> > + out->submodule_prefix = xstrdup(path);
> > + out->submodule_prefix = xstrfmt("%s%s/",
> > + the_repository->submodule_prefix ?
> > + the_repository->submodule_prefix :
> > + "", path);
> > +
> > + strbuf_release(&sb);
> > + return 0;
> > +}
>
> Based on the recent test coverage report [1], this xstrfmt() call is never
> run witha non-null the_repository->submodule_prefix. Is there a way we can
> exercise that branch?No it's dead code, actually. the_repository never has submodule_prefix set as it is the main repository. So this is overly cautious to enable the 'any repo' case. In a resend we'll go with xstrdup(path);