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

Re: [PATCH 1/5] submodule: prepare for recursive checkout of submodules

From
Jens Lehmann <jens.lehmann@web.de>
Date
Dec 27, 2013, 13:42 UTC
Message-ID
<52BD83DE.7070104@web.de>
In-Reply-To
<20131226160239.GM20443@google.com>
Am 26.12.2013 17:02, schrieb Jonathan Nieder:
Show 12 quoted lines
> From: Jens Lehmann <Jens.Lehmann@web.de>
> Date: Mon, 18 Jun 2012 22:17:59 +0200
> 
> This commit adds the functions needed for configuration, for setting the
> default behavior and for determining if a submodule path should be updated
> automatically.
> 
> Signed-off-by: Jens Lehmann <Jens.Lehmann@web.de>
> Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
> ---
> Should probably be squashed into a patch that uses and documents this
> configuration.

I'm not so sure. At the end of the day at least am, bisect, checkout, checkout-index, cherry-pick, merge, pull, read-tree, rebase, reset & stash should have learned this option (and all porcelain must honor the autoupdate setting by default, plumbing only when requested by giving the "--recurse-submodules=config" option to make life easier for scripting). And I think they should learn this one command per commit, making this one - and the yet-to-be-programmed one introducing the autoupdate flag - the base for them.

Show 86 quoted lines
>  submodule.c | 36 ++++++++++++++++++++++++++++++++++++
>  submodule.h |  3 +++
>  2 files changed, 39 insertions(+)
> 
> diff --git a/submodule.c b/submodule.c
> index 613857e..3f18d4d 100644
> --- a/submodule.c
> +++ b/submodule.c
> @@ -16,6 +16,8 @@ static struct string_list config_name_for_path;
>  static struct string_list config_fetch_recurse_submodules_for_name;
>  static struct string_list config_ignore_for_name;
>  static int config_fetch_recurse_submodules = RECURSE_SUBMODULES_ON_DEMAND;
> +static int config_update_recurse_submodules = RECURSE_SUBMODULES_OFF;
> +static int option_update_recurse_submodules = RECURSE_SUBMODULES_DEFAULT;
>  static struct string_list changed_submodule_paths;
>  static int initialized_fetch_ref_tips;
>  static struct sha1_array ref_tips_before_fetch;
> @@ -382,6 +384,34 @@ int parse_fetch_recurse_submodules_arg(const char *opt, const char *arg)
>  	}
>  }
>  
> +int parse_update_recurse_submodules_arg(const char *opt, const char *arg)
> +{
> +	switch (git_config_maybe_bool(opt, arg)) {
> +	case 1:
> +		return RECURSE_SUBMODULES_ON;
> +	case 0:
> +		return RECURSE_SUBMODULES_OFF;
> +	default:
> +		if (!strcmp(arg, "checkout"))
> +			return RECURSE_SUBMODULES_ON;
> +		die("bad %s argument: %s", opt, arg);
> +	}
> +}
> +
> +int submodule_needs_update(const char *path)
> +{
> +	struct string_list_item *path_option;
> +	path_option = unsorted_string_list_lookup(&config_name_for_path, path);
> +	if (!path_option)
> +		return 0;
> +
> +	/* update can't be "none", "merge" or "rebase" */
> +
> +	if (option_update_recurse_submodules != RECURSE_SUBMODULES_DEFAULT)
> +		return 1;
> +	return config_update_recurse_submodules != RECURSE_SUBMODULES_OFF;
> +}
> +
>  void show_submodule_summary(FILE *f, const char *path,
>  		const char *line_prefix,
>  		unsigned char one[20], unsigned char two[20],
> @@ -589,6 +619,12 @@ int push_unpushed_submodules(unsigned char new_sha1[20], const char *remotes_nam
>  	return ret;
>  }
>  
> +void set_config_update_recurse_submodules(int default_value, int option_value)
> +{
> +	config_update_recurse_submodules = default_value;
> +	option_update_recurse_submodules = option_value;
> +}
> +
>  static int is_submodule_commit_present(const char *path, unsigned char sha1[20])
>  {
>  	int is_present = 0;
> diff --git a/submodule.h b/submodule.h
> index 7beec48..055918c 100644
> --- a/submodule.h
> +++ b/submodule.h
> @@ -22,12 +22,15 @@ void gitmodules_config(void);
>  int parse_submodule_config_option(const char *var, const char *value);
>  void handle_ignore_submodules_arg(struct diff_options *diffopt, const char *);
>  int parse_fetch_recurse_submodules_arg(const char *opt, const char *arg);
> +int parse_update_recurse_submodules_arg(const char *opt, const char *arg);
> +int submodule_needs_update(const char *path);
>  void show_submodule_summary(FILE *f, const char *path,
>  		const char *line_prefix,
>  		unsigned char one[20], unsigned char two[20],
>  		unsigned dirty_submodule, const char *meta,
>  		const char *del, const char *add, const char *reset);
>  void set_config_fetch_recurse_submodules(int value);
> +void set_config_update_recurse_submodules(int default_value, int option_value);
>  void check_for_new_submodule_commits(unsigned char new_sha1[20]);
>  int fetch_populated_submodules(const struct argv_array *options,
>  			       const char *prefix, int command_line_option,
> 
Previous: Jonathan NiederNext: Jonathan Nieder
Message 3 of 11 in “git checkout --recurse-submodules”
  1. 0/5 git checkout --recurse-submodulesJonathan Nieder, Dec 26, 2013
  2. 1/5 submodule: prepare for recursive checkout of submodulesJonathan Nieder, Dec 26, 2013
  3. Jens LehmannDec 27, 2013
  4. 2/5 submodule: teach unpack_trees() to remove submodule contentsJonathan Nieder, Dec 26, 2013
  5. Jens LehmannDec 27, 2013
  6. 3/5 submodule: teach unpack_trees() to repopulate submodulesJonathan Nieder, Dec 26, 2013
  7. 4/5 submodule: teach unpack_trees() to update submodulesJonathan Nieder, Dec 26, 2013
  8. 5/5 Teach checkout to recursively checkout submodulesJonathan Nieder, Dec 26, 2013
  9. Jens LehmannDec 27, 2013
  10. Junio C HamanoDec 26, 2013
  11. Jens LehmannDec 27, 2013

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.