Re: [RFC PATCH 2/4] fetch: refactor --submodule-prefix
- From
Ævar Arnfjörð Bjarmason <avarab@gmail.com>
- Date
- Nov 9, 2022, 03:06 UTC
- Message-ID
- <221109.8635asrfer.gmgdl@evledraar.gmail.com>
- In-Reply-To
- <20221109004708.97668-3-chooglen@google.com>
On Tue, Nov 08 2022, Glen Choo wrote:
Show 5 quoted lines
> Since we've previously documented that repository.submodule_prefix is > only set for submodules, introduce repository.is_submodule for > distinguishing between the_repository and a submodule (although, this > turns out to be unused, since no caller uses repository.submodule_prefix > for that purpose).
There's more to chew on here, but just briefly on this:
Show 34 quoted lines
> diff --git a/repository.c b/repository.c
> index 5d166b692c..1d454a0ac4 100644
> --- a/repository.c
> +++ b/repository.c
> @@ -229,6 +229,7 @@ int repo_submodule_init(struct repository *subrepo,
> }
> }
>
> + subrepo->is_submodule = 1;
> subrepo->submodule_prefix = xstrfmt("%s%s/",
> superproject->submodule_prefix ?
> superproject->submodule_prefix :
> diff --git a/repository.h b/repository.h
> index 24316ac944..1bc4afc2b6 100644
> --- a/repository.h
> +++ b/repository.h
> @@ -119,10 +119,15 @@ struct repository {
> */
> char *worktree;
>
> + /*
> + * Whether this struct represents a submodule of this process's main
> + * repository.
> + */
> + int is_submodule;
> +
> /*
> * Path from the root of the top-level superproject down to this
> - * repository. This is only non-NULL if the repository is initialized
> - * as a submodule of another repository.
> + * repository.
> */
> char *submodule_prefix;
> Just deleting that "is_submodule" header addition and the assignment you added on top of 4/4 has this series compile. So "this turns out to be unused" ... because it's added here, but never used? So why do we need to add it?