From: Junio C Hamano <gitster@pobox•com>
To: Brandon Williams <bmwill@google•com>
Cc: Heiko Voigt <hvoigt@hvoigt•net>,
sbeller@google•com, jrnieder@gmail•com, Jens.Lehmann@web•de,
git@vger•kernel.org
Subject: Re: [PATCH v4 3/3] submodule: simplify decision tree whether to or not to fetch
Date: Thu, 19 Oct 2017 09:36:47 +0900 [thread overview]
Message-ID: <xmqqshegj7mo.fsf@gitster.mtv.corp.google.com> (raw)
In-Reply-To: <20171018180322.GA155019@google.com> (Brandon Williams's message of "Wed, 18 Oct 2017 11:03:22 -0700")
Brandon Williams <bmwill@google•com> writes:
> On 10/16, Heiko Voigt wrote:
>> To make extending this logic later easier.
>
> This makes things so much clearer, thanks!
I agree that it is clear to see what the code after the patch does,
but the code before the patch is so convoluted to follow that it is
a bit hard to see if the code before and after are doing the same
thing, though ;-)
>
>>
>> Signed-off-by: Heiko Voigt <hvoigt@hvoigt•net>
>> ---
>> submodule.c | 74 ++++++++++++++++++++++++++++++-------------------------------
>> 1 file changed, 37 insertions(+), 37 deletions(-)
>>
>> diff --git a/submodule.c b/submodule.c
>> index 71d1773e2e..82d206eb65 100644
>> --- a/submodule.c
>> +++ b/submodule.c
>> @@ -1187,6 +1187,31 @@ struct submodule_parallel_fetch {
>> };
>> #define SPF_INIT {0, ARGV_ARRAY_INIT, NULL, NULL, 0, 0, 0, 0}
>>
>> +static int get_fetch_recurse_config(const struct submodule *submodule,
>> + struct submodule_parallel_fetch *spf)
>> +{
>> + if (spf->command_line_option != RECURSE_SUBMODULES_DEFAULT)
>> + return spf->command_line_option;
>> +
>> + if (submodule) {
>> + char *key;
>> + const char *value;
>> +
>> + int 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);
>> +
>> + if (fetch_recurse != RECURSE_SUBMODULES_NONE)
>> + /* local config overrules everything except commandline */
>> + return fetch_recurse;
>> + }
>> +
>> + return spf->default_option;
>> +}
>> +
>> static int get_next_submodule(struct child_process *cp,
>> struct strbuf *err, void *data, void **task_cb)
>> {
>> @@ -1214,46 +1239,21 @@ static int get_next_submodule(struct child_process *cp,
>> }
>> }
>>
>> - default_argv = "yes";
>> - if (spf->command_line_option == RECURSE_SUBMODULES_DEFAULT) {
>> - 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);
>> - }
>> -
>> - if (fetch_recurse != RECURSE_SUBMODULES_NONE) {
>> - if (fetch_recurse == RECURSE_SUBMODULES_OFF)
>> - continue;
>> - if (fetch_recurse == RECURSE_SUBMODULES_ON_DEMAND) {
>> - if (!unsorted_string_list_lookup(&changed_submodule_names,
>> - submodule->name))
>> - continue;
>> - default_argv = "on-demand";
>> - }
>> - } else {
>> - if (spf->default_option == RECURSE_SUBMODULES_OFF)
>> - continue;
>> - if (spf->default_option == 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))
>> + {
>> + 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.14.1.145.gb3622a4
>>
next prev parent reply other threads:[~2017-10-19 0:37 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-10-16 13:56 [PATCH v4 0/3] implement fetching of moved submodules Heiko Voigt
2017-10-16 13:57 ` [PATCH v4 1/3] fetch: add test to make sure we stay backwards compatible Heiko Voigt
2017-10-17 17:56 ` Stefan Beller
2017-10-16 13:58 ` [PATCH v4 2/3] implement fetching of moved submodules Heiko Voigt
2017-10-17 17:47 ` Stefan Beller
2017-10-18 0:03 ` Junio C Hamano
2017-10-18 17:56 ` Stefan Beller
2017-10-19 0:35 ` Junio C Hamano
2017-10-19 18:11 ` [PATCH 1/2] t5526: check for name/path collision in submodule fetch Stefan Beller
2017-10-19 18:11 ` [PATCH 2/2] fetch, push: keep separate lists of submodules and gitlinks Stefan Beller
2017-10-23 14:12 ` Heiko Voigt
2017-10-23 18:05 ` Stefan Beller
2017-10-24 0:54 ` Junio C Hamano
2017-10-23 14:16 ` [PATCH 1/2] t5526: check for name/path collision in submodule fetch Heiko Voigt
2017-10-23 17:58 ` Stefan Beller
2017-10-19 23:34 ` [PATCH v4 2/3] implement fetching of moved submodules Stefan Beller
2017-10-16 13:59 ` [PATCH v4 3/3] submodule: simplify decision tree whether to or not to fetch Heiko Voigt
2017-10-17 18:22 ` Stefan Beller
2017-10-18 0:03 ` Junio C Hamano
2017-10-18 18:03 ` Brandon Williams
2017-10-19 0:36 ` Junio C Hamano [this message]
2017-10-19 15:38 ` Heiko Voigt
2017-10-19 19:16 ` Brandon Williams
2017-10-17 1:49 ` [PATCH v4 0/3] implement fetching of moved submodules Junio C Hamano
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=xmqqshegj7mo.fsf@gitster.mtv.corp.google.com \
--to=gitster@pobox$(echo .)com \
--cc=Jens.Lehmann@web$(echo .)de \
--cc=bmwill@google$(echo .)com \
--cc=git@vger$(echo .)kernel.org \
--cc=hvoigt@hvoigt$(echo .)net \
--cc=jrnieder@gmail$(echo .)com \
--cc=sbeller@google$(echo .)com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox