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

Re: [PATCHv9 1/6] submodule-config: keep update strategy around

From
Junio C Hamano <gitster@pobox.com>
Date
Feb 9, 2016, 21:08 UTC
Message-ID
<xmqqh9hh382i.fsf@gitster.mtv.corp.google.com>
In-Reply-To
<1455051274-15256-2-git-send-email-sbeller@google.com>
Stefan Beller <sbeller@google.com> writes:
Show 35 quoted lines
> Currently submodule.<name>.update is only handled by git-submodule.sh.
> C code will start to need to make use of that value as more of the
> functionality of git-submodule.sh moves into library code in C.
>
> Add the update field to 'struct submodule' and populate it so it can
> be read as sm->update or from sm->update_command.
>
> Signed-off-by: Stefan Beller <sbeller@google.com>
> ---
>  submodule-config.c | 22 ++++++++++++++++++++++
>  submodule-config.h | 11 +++++++++++
>  2 files changed, 33 insertions(+)
>
> diff --git a/submodule-config.c b/submodule-config.c
> index afe0ea8..a1af5de 100644
> --- a/submodule-config.c
> +++ b/submodule-config.c
> @@ -194,6 +194,8 @@ static struct submodule *lookup_or_create_by_name(struct submodule_cache *cache,
>  
>  	submodule->path = NULL;
>  	submodule->url = NULL;
> +	submodule->update = SM_UPDATE_UNSPECIFIED;
> +	submodule->update_command = NULL;
>  	submodule->fetch_recurse = RECURSE_SUBMODULES_NONE;
>  	submodule->ignore = NULL;
>  
> @@ -311,6 +313,26 @@ static int parse_config(const char *var, const char *value, void *data)
>  			free((void *) submodule->url);
>  			submodule->url = xstrdup(value);
>  		}
> +	} else if (!strcmp(item.buf, "update")) {
> +		if (!value)
> +			ret = config_error_nonbool(var);
> +		else if (!me->overwrite &&
> +		    submodule->update != SM_UPDATE_UNSPECIFIED)
Funny indentation here (locally fixable).

Thanks to this change, we do not need "'!= NULL' removal" for this location in 2/6.

Show 47 quoted lines
> +			warn_multiple_config(me->commit_sha1, submodule->name,
> +					     "update");
> +		else {
> +			submodule->update_command = NULL;
> +			if (!strcmp(value, "none"))
> +				submodule->update = SM_UPDATE_NONE;
> +			else if (!strcmp(value, "checkout"))
> +				submodule->update = SM_UPDATE_CHECKOUT;
> +			else if (!strcmp(value, "rebase"))
> +				submodule->update = SM_UPDATE_REBASE;
> +			else if (!strcmp(value, "merge"))
> +				submodule->update = SM_UPDATE_MERGE;
> +			else if (!skip_prefix(value, "!", &submodule->update_command))
> +				die(_("invalid value for %s"), var);
> +		}
>  	}
>  
>  	strbuf_release(&name);
> diff --git a/submodule-config.h b/submodule-config.h
> index 9061e4e..e3bd56e 100644
> --- a/submodule-config.h
> +++ b/submodule-config.h
> @@ -4,6 +4,15 @@
>  #include "hashmap.h"
>  #include "strbuf.h"
>  
> +enum submodule_update_type {
> +	SM_UPDATE_CHECKOUT,
> +	SM_UPDATE_REBASE,
> +	SM_UPDATE_MERGE,
> +	SM_UPDATE_NONE,
> +	SM_UPDATE_COMMAND,
> +	SM_UPDATE_UNSPECIFIED
> +};
> +
>  /*
>   * Submodule entry containing the information about a certain submodule
>   * in a certain revision.
> @@ -14,6 +23,8 @@ struct submodule {
>  	const char *url;
>  	int fetch_recurse;
>  	const char *ignore;
> +	enum submodule_update_type update;
> +	const char *update_command;
>  	/* the sha1 blob id of the responsible .gitmodules file */
>  	unsigned char gitmodules_sha1[20];
>  };
Previous: Stefan BellerNext: Stefan Beller
Message 3 of 30 in “[PATCHv9 0/6] Expose submodule parallelism to the user”
  1. Stefan BellerFeb 9, 2016
  2. 1/6 submodule-config: keep update strategy aroundStefan Beller, Feb 9, 2016
  3. Junio C HamanoFeb 9, 2016
  4. Stefan BellerFeb 9, 2016
  5. Junio C HamanoFeb 9, 2016
  6. Jonathan NiederFeb 9, 2016
  7. Junio C HamanoFeb 9, 2016
  8. Junio C HamanoFeb 11, 2016
  9. 2/6 submodule-config: drop check against NULLStefan Beller, Feb 9, 2016
  10. Jonathan NiederFeb 9, 2016
  11. 3/6 fetching submodules: respect `submodule.fetchJobs` config optionStefan Beller, Feb 9, 2016
  12. Junio C HamanoFeb 9, 2016
  13. Jonathan NiederFeb 9, 2016
  14. Stefan BellerFeb 10, 2016
  15. Junio C HamanoFeb 10, 2016
  16. Junio C HamanoFeb 10, 2016
  17. 4/6 git submodule update: have a dedicated helper for cloningStefan Beller, Feb 9, 2016
  18. Junio C HamanoFeb 9, 2016
  19. Jonathan NiederFeb 10, 2016
  20. Jacob KellerFeb 10, 2016
  21. Stefan BellerFeb 10, 2016
  22. Jacob KellerFeb 11, 2016
  23. 5/6 submodule update: expose parallelism to the userStefan Beller, Feb 9, 2016
  24. 6/6 clone: allow an explicit argument for parallel submodule clonesStefan Beller, Feb 9, 2016
  25. Junio C HamanoFeb 9, 2016
  26. Stefan BellerFeb 9, 2016
  27. Junio C HamanoFeb 9, 2016
  28. Junio C HamanoFeb 11, 2016
  29. Junio C HamanoFeb 11, 2016
  30. Stefan BellerFeb 11, 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.