Re: [PATCH 2/2] submodule: skip redundant active entries when pattern covers path
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Jul 24, 2025, 21:21 UTC
- Message-ID
- <xmqq1pq5z3n3.fsf@gitster.g>
- In-Reply-To
- <20250724152418.45226-3-jayatheerthkulkarni2005@gmail.com>
K Jayatheerth <jayatheerthkulkarni2005@gmail.com> writes:
Show 10 quoted lines
> @@ -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.
Show 7 quoted lines
> @@ -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?