Re: [PATCH 06/15] fetch: don't overlay config with submodule-config
- From
- Brandon Williams <bmwill@google.com>
- Date
- Jul 25, 2017, 23:48 UTC
- Message-ID
- <20170725234825.GC71799@google.com>
- In-Reply-To
- <CAGZ79kZGFhiNAYqJ9hZqDLEZt-9jYQ=o0ej2VmO0E=pZg85Fsg@mail.gmail.com>
On 07/25, Stefan Beller wrote:
Show 56 quoted lines
> On Tue, Jul 25, 2017 at 2:39 PM, Brandon Williams <bmwill@google.com> wrote:
> > Don't rely on overlaying the repository's config on top of the
> > submodule-config, instead query the repository's config directly for the
> > fetch_recurse field.
> >
> > Signed-off-by: Brandon Williams <bmwill@google.com>
>
> Reviewed-by: Stefan Beller <sbeller@google.com>
>
> > ---
> > builtin/fetch.c | 1 -
> > submodule.c | 24 +++++++++++++++++-------
> > 2 files changed, 17 insertions(+), 8 deletions(-)
> >
> > diff --git a/builtin/fetch.c b/builtin/fetch.c
> > index d84c26391..3fe99073d 100644
> > --- a/builtin/fetch.c
> > +++ b/builtin/fetch.c
> > @@ -1362,7 +1362,6 @@ int cmd_fetch(int argc, const char **argv, const char *prefix)
> >
> > if (recurse_submodules != RECURSE_SUBMODULES_OFF) {
> > gitmodules_config();
> > - git_config(submodule_config, NULL);
> > }
> >
> > if (all) {
> > diff --git a/submodule.c b/submodule.c
> > index 8b9e48a61..c5058a4b8 100644
> > --- a/submodule.c
> > +++ b/submodule.c
> > @@ -1210,14 +1210,24 @@ static int get_next_submodule(struct child_process *cp,
> >
> > default_argv = "yes";
> > if (spf->command_line_option == RECURSE_SUBMODULES_DEFAULT) {
> > - if (submodule &&
> > - submodule->fetch_recurse !=
> > - RECURSE_SUBMODULES_NONE) {
> > - if (submodule->fetch_recurse ==
> > - RECURSE_SUBMODULES_OFF)
> > + int fetch_recurse = RECURSE_SUBMODULES_NONE;
> > +
> > + if (submodule) {
> > + char *key;
> > + const char *value;
> > +
> > + fetch_recurse = submodule->fetch_recurse;
> > + key = xstrfmt("submodule.%s.fetchRecurseSubmodules", submodule->name);
> > + if (!repo_config_get_string_const(the_repository, key, &value)) {
> > + fetch_recurse = parse_fetch_recurse_submodules_arg(key, value);
> > + }
> > + free(key);
> > + }
>
> I wonder if it would be better to parse this in builtin/fetch.c#git_fetch_config
> and then pass it in here as a parameter, instead of looking it up directly here?
> That way it is easier to keep track of what a builtin pays attention to.Really the fact that you can configure individual submodules in .gitmodules to be fetched recursively or not is a terrible design IMO. Also this is a per-submodule configuration so having it in builtin/fetch.c would be incredibly annoying to handle.
Show 15 quoted lines
>
>
> > +
> > + if (fetch_recurse != RECURSE_SUBMODULES_NONE) {
> > + if (fetch_recurse == RECURSE_SUBMODULES_OFF)
> > continue;
> > - if (submodule->fetch_recurse ==
> > - RECURSE_SUBMODULES_ON_DEMAND) {
> > + if (fetch_recurse == RECURSE_SUBMODULES_ON_DEMAND) {
> > if (!unsorted_string_list_lookup(&changed_submodule_paths, ce->name))
> > continue;
> > default_argv = "on-demand";
> > --
> > 2.14.0.rc0.400.g1c36432dff-goog
> >-- Brandon Williams