git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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?

Previous: K JayatheerthNext: K Jayatheerth
Message 5 of 8 in “Avoid submodule overwritten and skip redundant active entries”
  1. 0/2 Avoid submodule overwritten and skip redundant active entriesK Jayatheerth, Jul 24, 2025
  2. 1/2 submodule: prevent overwriting .gitmodules on path reuseK Jayatheerth, Jul 24, 2025
  3. Junio C HamanoJul 24, 2025
  4. 2/2 submodule: skip redundant active entries when pattern covers pathK Jayatheerth, Jul 24, 2025
  5. Junio C HamanoJul 24, 2025
  6. 0/2 Avoid submodule overwritten and skip redundant active entriesK Jayatheerth, Jul 25, 2025
  7. 1/2 submodule: prevent overwriting .gitmodules on path reuseK Jayatheerth, Jul 25, 2025
  8. 2/2 submodule: skip redundant active entries when pattern covers pathK Jayatheerth, Jul 25, 2025

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.