On 08/17, Stefan Beller wrote:
> On Thu, Aug 17, 2017 at 4:00 AM, Heiko Voigt <[email protected]> wrote:
> > To make extending this logic later easier.
> >
> > Signed-off-by: Heiko Voigt <[email protected]>
> > ---
> > I am quite sure I replicated the same logic but a few more eyes would be
> > appreciated.
>
> A code cleanup is appreciated!
>
> I thought Brandon had a series in flight doing a very similar cleanup here,
> but in master..pu there is nothing to be found.
Yeah there are 2 series in flight which will probably conflict here.
bw/grep-recurse-submodules and bw/submodule-config-cleanup
>
> > Cheers Heiko
>
> The code looks good to me.
>
> Cheers!
> Stefan
>
> >
> > submodule.c | 55 +++++++++++++++++++++++++++----------------------------
> > 1 file changed, 27 insertions(+), 28 deletions(-)
> >
> > diff --git a/submodule.c b/submodule.c
> > index 3ed78ac..a1011f4 100644
> > --- a/submodule.c
> > +++ b/submodule.c
> > @@ -1171,6 +1171,21 @@ int submodule_touches_in_range(struct object_id
> > *excl_oid,
> > return ret;
> > }
> >
> > +static int get_fetch_recurse_config(const struct submodule *submodule, int
> > command_line_option)
> > +{
> > + if (command_line_option != RECURSE_SUBMODULES_DEFAULT)
> > + return command_line_option;
> > +
> > + if (submodule && submodule->fetch_recurse !=
> > RECURSE_SUBMODULES_NONE)
> > + /* local config overrules everything except commandline */
> > + return submodule->fetch_recurse;
> > +
> > + if (gitmodules_is_unmerged)
> > + return RECURSE_SUBMODULES_OFF;
> > +
> > + return config_fetch_recurse_submodules;
> > +}
> > +
> > struct submodule_parallel_fetch {
> > int count;
> > struct argv_array args;
> > @@ -1203,37 +1218,21 @@ static int get_next_submodule(struct child_process
> > *cp,
> > if (!submodule)
> > submodule = submodule_from_name(&null_oid,
> > ce->name);
> >
> > - 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)
> > - continue;
> > - if (submodule->fetch_recurse ==
> > -
> > RECURSE_SUBMODULES_ON_DEMAND) {
> > - if
> > (!unsorted_string_list_lookup(&changed_submodule_names,
> > -
> > submodule->name))
> > - continue;
> > - default_argv = "on-demand";
> > - }
> > - } else {
> > - if ((config_fetch_recurse_submodules ==
> > RECURSE_SUBMODULES_OFF) ||
> > - gitmodules_is_unmerged)
> > - continue;
> > - if (config_fetch_recurse_submodules ==
> > RECURSE_SUBMODULES_ON_DEMAND) {
> > - if
> > (!unsorted_string_list_lookup(&changed_submodule_names,
> > -
> > submodule->name))
> > - continue;
> > - default_argv = "on-demand";
> > - }
> > - }
> > - } else if (spf->command_line_option ==
> > RECURSE_SUBMODULES_ON_DEMAND) {
> > - if
> > (!unsorted_string_list_lookup(&changed_submodule_names,
> > + switch (get_fetch_recurse_config(submodule,
> > spf->command_line_option))
> > + {
> > + default:
> > + case RECURSE_SUBMODULES_DEFAULT:
> > + case RECURSE_SUBMODULES_ON_DEMAND:
> > + if (!submodule ||
> > !unsorted_string_list_lookup(&changed_submodule_names,
> > submodule->name))
> > continue;
> > default_argv = "on-demand";
> > + break;
> > + case RECURSE_SUBMODULES_ON:
> > + default_argv = "yes";
> > + break;
> > + case RECURSE_SUBMODULES_OFF:
> > + continue;
> > }
> >
> > strbuf_addf(&submodule_path, "%s/%s", spf->work_tree,
> > ce->name);
> > --
> > 2.0.0.274.g6b2cd91
> >
--
Brandon Williams