Re: [PATCH v3 06/10] submodule update: add `--init-active` switch
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Mar 14, 2017, 19:28 UTC
- Message-ID
- <xmqqr31ziroz.fsf@gitster.mtv.corp.google.com>
- In-Reply-To
- <20170313214341.172676-7-bmwill@google.com>
Brandon Williams <bmwill@google.com> writes:
Show 15 quoted lines
> +static void module_list_active(struct module_list *list)
> +{
> + int i;
> +
> + if (read_cache() < 0)
> + die(_("index file corrupt"));
> +
> + gitmodules_config();
> +
> + for (i = 0; i < active_nr; i++) {
> + const struct cache_entry *ce = active_cache[i];
> +
> + if (!S_ISGITLINK(ce->ce_mode) ||
> + !is_submodule_initialized(ce->name))
> + continue;This, because "is_submodule_initialized()" is not "is it initialized?" but "is it interesting?", will catch a submodule that used to be uninteresting but has become interesting (e.g. a new submodule added to somewhere in "lib/" when submodule.active lists "lib/" as one of the pathspecs to match interesting submodules) and automatically updates it.
I anticipate that a corresponding "please deinitialize ones that are no longer interesting" coming in the series ;-) Without it, the interested set will only grow without shrinking.
Show 11 quoted lines
> + ALLOC_GROW(list->entries, list->nr + 1, list->alloc); > + list->entries[list->nr++] = ce; > + while (i + 1 < active_nr && > + !strcmp(ce->name, active_cache[i + 1]->name)) > + /* > + * Skip entries with the same name in different stages > + * to make sure an entry is returned only once. > + */ > + i++; > + } > +}