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

Re: [PATCH 2/4] submodule-config: keep groups around

From
Junio C Hamano <gitster@pobox.com>
Date
Jan 20, 2016, 21:23 UTC
Message-ID
<xmqqwpr43pyz.fsf@gitster.mtv.corp.google.com>
In-Reply-To
<1453260880-628-3-git-send-email-sbeller@google.com>
Stefan Beller <sbeller@google.com> writes:
Show 18 quoted lines
> We need the submodule groups in a later patch.
>
> Signed-off-by: Stefan Beller <sbeller@google.com>
> ---
>  submodule-config.c | 13 +++++++++++++
>  submodule-config.h |  1 +
>  2 files changed, 14 insertions(+)
>
> diff --git a/submodule-config.c b/submodule-config.c
> index a32259e..b5453d0 100644
> --- a/submodule-config.c
> +++ b/submodule-config.c
> @@ -60,6 +60,8 @@ static void free_one_config(struct submodule_entry *entry)
>  {
>  	free((void *) entry->config->path);
>  	free((void *) entry->config->name);
> +	if (entry->config->groups)
> +		string_list_clear(entry->config->groups, 0);

You are allocating entry->config->groups itself in the in the hunk around ll.327, so that also need to be freed, I would think.

Show 38 quoted lines
>  	free(entry->config);
>  }
>  
> @@ -184,6 +186,7 @@ static struct submodule *lookup_or_create_by_name(struct submodule_cache *cache,
>  	submodule->update = NULL;
>  	submodule->fetch_recurse = RECURSE_SUBMODULES_NONE;
>  	submodule->ignore = NULL;
> +	submodule->groups = NULL;
>  
>  	hashcpy(submodule->gitmodules_sha1, gitmodules_sha1);
>  
> @@ -324,6 +327,16 @@ static int parse_specific_submodule_config(const char *subsection, int subsectio
>  			free((void *) submodule->update);
>  			submodule->update = xstrdup(value);
>  		}
> +	} else if (!strcmp(key, "group")) {
> +		if (!value)
> +			ret = config_error_nonbool(var);
> +		else {
> +			if (!submodule->groups) {
> +				submodule->groups = xmalloc(sizeof(*submodule->groups));
> +				string_list_init(submodule->groups, 1);
> +			}
> +			string_list_insert(submodule->groups, value);
> +		}
>  	}
>  
>  	return ret;
> diff --git a/submodule-config.h b/submodule-config.h
> index d9bbf9a..332f5be 100644
> --- a/submodule-config.h
> +++ b/submodule-config.h
> @@ -17,6 +17,7 @@ struct submodule {
>  	const char *update;
>  	/* the sha1 blob id of the responsible .gitmodules file */
>  	unsigned char gitmodules_sha1[20];
> +	struct string_list *groups;
>  };

Is there a case where you need to enumerate and show the groups a submodule belongs to to the end users? Using string_list_insert() to manage this list would mean you will lose the original ordering you saw the list of groups in their .gitmodules files, which may or may not matter. I'd assume that the ordering should not matter, but that is something the user may want to see documented.

>  
>  int parse_fetch_recurse_submodules_arg(const char *opt, const char *arg);
Previous: Stefan BellerNext: Stefan Beller
Message 9 of 27 in “Submodule Groups”
  1. 0/4 Submodule GroupsStefan Beller, Jan 20, 2016
  2. 1/4 git submodule: Teach add to accept --groupStefan Beller, Jan 20, 2016
  3. Junio C HamanoJan 20, 2016
  4. Stefan BellerJan 20, 2016
  5. Junio C HamanoJan 21, 2016
  6. Stefan BellerJan 21, 2016
  7. Junio C HamanoJan 21, 2016
  8. 2/4 submodule-config: keep groups aroundStefan Beller, Jan 20, 2016
  9. Junio C HamanoJan 20, 2016
  10. Stefan BellerJan 21, 2016
  11. Junio C HamanoJan 21, 2016
  12. 3/4 submodule update: Initialize all group-selected submodules by defaultStefan Beller, Jan 20, 2016
  13. Junio C HamanoJan 20, 2016
  14. Stefan BellerJan 21, 2016
  15. Junio C HamanoJan 21, 2016
  16. Stefan BellerJan 21, 2016
  17. Junio C HamanoJan 21, 2016
  18. Junio C HamanoJan 21, 2016
  19. 4/4 builtin/clone: support submodule groupsStefan Beller, Jan 20, 2016
  20. Junio C HamanoJan 20, 2016
  21. Sebastian SchuberthJan 21, 2016
  22. Stefan BellerJan 21, 2016
  23. Junio C HamanoJan 21, 2016
  24. Junio C HamanoJan 21, 2016
  25. Stefan BellerJan 21, 2016
  26. Junio C HamanoJan 21, 2016
  27. Sebastian SchuberthJan 22, 2016

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.