Subject: Re: [PATCH 2/2] submodule: skip redundant active entries when pattern covers path

From: Junio C Hamano <[email-masked]>
Date: Thu, 24 Jul 2025 14:21:20 -0700

K Jayatheerth <[email-masked]> writes:

> @@ -3308,6 +3310,9 @@ static void configure_added_submodule(struct add_data *add_data)
>  	struct child_process add_submod = CHILD_PROCESS_INIT;
>  	struct child_process add_gitmodules = CHILD_PROCESS_INIT;
>  
> +	const struct string_list *values;
> +	size_t i;
> +	int matched = 0;
>  	key = xstrfmt("submodule.%s.url", add_data->sm_name);
>  	git_config_set_gently(key, add_data->realrepo);
>  	free(key);

The blank line should be between the end of block of decls
(i.e. "int matched = 0") and the first statement (i.e. "key =
xstrfmt(...)"), not there.  You probably do not need "i" in such a
wide scope; just use

	for (size_t i = 0; i < values->nr; i++)

in the only loop that uses it.

> @@ -3349,20 +3354,28 @@ static void configure_added_submodule(struct add_data *add_data)
>  	 * is_submodule_active(), since that function needs to find
>  	 * out the value of "submodule.active" again anyway.
>  	 */
> -	if (!git_config_get("submodule.active")) {
> +	if (git_config_get("submodule.active") || /* key absent */
> +	    git_config_get_string_multi("submodule.active", &values)) {

Hmph, do we need two calls here, or would a single call to
get_string_multi() sufficient to learn what we want here?  When
there is no such key, the function may fail (or succeed and leave
values->nr == 0), and either way, we can tell that there is no such
key, right?