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

Re: [PATCH 07/14] update submodules: introduce is_interesting_submodule

From
BWBrandon Williams <bmwill@google.com>
Date
Feb 15, 2017, 17:04 UTC
Message-ID
<20170215170441.GB29448@google.com>
In-Reply-To
<20170215003423.20245-8-sbeller@google.com>
On 02/14, Stefan Beller wrote:
Show 34 quoted lines
> In later patches we introduce the --recurse-submodule flag for commands
> that modify the working directory, e.g. git-checkout.
> 
> It is potentially expensive to check if a submodule needs an update,
> because a common theme to interact with submodules is to spawn a child
> process for each interaction.
> 
> So let's introduce a function that pre checks if a submodule needs
> to be checked for an update.
> 
> Signed-off-by: Stefan Beller <sbeller@google.com>
> ---
>  submodule.c | 26 ++++++++++++++++++++++++++
>  submodule.h |  8 ++++++++
>  2 files changed, 34 insertions(+)
> 
> diff --git a/submodule.c b/submodule.c
> index c0060c29f2..4c33374ae8 100644
> --- a/submodule.c
> +++ b/submodule.c
> @@ -551,6 +551,32 @@ void set_config_update_recurse_submodules(int value)
>  	config_update_recurse_submodules = value;
>  }
>  
> +int submodules_interesting_for_update(void)
> +{
> +	/*
> +	 * Update can't be "none", "merge" or "rebase",
> +	 * treat any value as OFF, except an explicit ON.
> +	 */
> +	return config_update_recurse_submodules == RECURSE_SUBMODULES_ON;
> +}
> +
> +int is_interesting_submodule(const struct cache_entry *ce)

Is there perhaps a more descriptive function name we could use instead of "is_interesting"? The problem is that its difficult to know why its interesting or for what purpose it is interesting.

Show 41 quoted lines
> +{
> +	const struct submodule *sub;
> +
> +	if (!S_ISGITLINK(ce->ce_mode))
> +		return 0;
> +
> +	if (!submodules_interesting_for_update())
> +		return 0;
> +
> +	sub = submodule_from_path(null_sha1, ce->name);
> +	if (!sub)
> +		return 0;
> +
> +	return sub->update_strategy.type != SM_UPDATE_NONE;
> +}
> +
>  static int has_remote(const char *refname, const struct object_id *oid,
>  		      int flags, void *cb_data)
>  {
> diff --git a/submodule.h b/submodule.h
> index c4e1ac828e..84b67a7c4a 100644
> --- a/submodule.h
> +++ b/submodule.h
> @@ -59,6 +59,14 @@ extern void show_submodule_inline_diff(FILE *f, const char *path,
>  		const struct diff_options *opt);
>  extern void set_config_fetch_recurse_submodules(int value);
>  extern void set_config_update_recurse_submodules(int value);
> +
> +/*
> + * Traditionally Git ignored changes made for submodules.
> + * This function checks if we are interested in the given submodule
> + * for any kind of operation.
> + */
> +extern int submodules_interesting_for_update(void);
> +extern int is_interesting_submodule(const struct cache_entry *ce);
>  extern void check_for_new_submodule_commits(unsigned char new_sha1[20]);
>  extern int fetch_populated_submodules(const struct argv_array *options,
>  			       const char *prefix, int command_line_option,
> -- 
> 2.12.0.rc0.16.gd1691994b4.dirty
> 
-- 
Brandon Williams
Previous: Stefan BellerNext: Stefan Beller
Message 8 of 94 in “Checkout aware of Submodules!”
  1. 00/14 Checkout aware of Submodules!Stefan Beller, Feb 15, 2017
  2. 01/14 lib-submodule-update.sh: reorder create_lib_submodule_repoStefan Beller, Feb 15, 2017
  3. brian m. carlsonFeb 15, 2017
  4. 02/14 lib-submodule-update.sh: define tests for recursing into submodulesStefan Beller, Feb 15, 2017
  5. Brandon WilliamsFeb 15, 2017
  6. Stefan BellerFeb 15, 2017
  7. 07/14 update submodules: introduce is_interesting_submoduleStefan Beller, Feb 15, 2017
  8. Brandon WilliamsFeb 15, 2017
  9. Stefan BellerFeb 15, 2017
  10. 06/14 update submodules: add a config option to determine if submodules are updatedStefan Beller, Feb 15, 2017
  11. 05/14 update submodules: add submodule config parsingStefan Beller, Feb 15, 2017
  12. Junio C HamanoFeb 15, 2017
  13. 11/14 unpack-trees: check if we can perform the operation for submodulesStefan Beller, Feb 15, 2017
  14. 10/14 unpack-trees: pass old oid to verify_clean_submoduleStefan Beller, Feb 15, 2017
  15. 09/14 update submodules: add submodule_go_from_toStefan Beller, Feb 15, 2017
  16. brian m. carlsonFeb 15, 2017
  17. 04/14 connect_work_tree_and_git_dir: safely create leading directoriesStefan Beller, Feb 15, 2017
  18. Junio C HamanoFeb 15, 2017
  19. Stefan BellerFeb 15, 2017
  20. Junio C HamanoFeb 15, 2017
  21. 13/14 entry.c: update submodules when interestingStefan Beller, Feb 15, 2017
  22. 14/14 builtin/checkout: add --recurse-submodules switchStefan Beller, Feb 15, 2017
  23. brian m. carlsonFeb 15, 2017
  24. Stefan BellerFeb 16, 2017
  25. 12/14 read-cache: remove_marked_cache_entries to wipe selected submodules.Stefan Beller, Feb 15, 2017
  26. 03/14 make is_submodule_populated gentlyStefan Beller, Feb 15, 2017
  27. Junio C HamanoFeb 15, 2017
  28. Stefan BellerFeb 15, 2017
  29. 08/14 update submodules: move up prepare_submodule_repo_envStefan Beller, Feb 15, 2017
  30. brian m. carlsonFeb 15, 2017
  31. Junio C HamanoFeb 15, 2017
  32. 00/14 Checkout aware of Submodules!Stefan Beller, Feb 16, 2017
  33. 05/15 connect_work_tree_and_git_dir: safely create leading directoriesStefan Beller, Feb 16, 2017
  34. Junio C HamanoFeb 16, 2017
  35. Stefan BellerFeb 16, 2017
  36. Junio C HamanoFeb 16, 2017
  37. 07/15 update submodules: add a config option to determine if submodules are updatedStefan Beller, Feb 16, 2017
  38. 03/15 lib-submodule-update.sh: define tests for recursing into submodulesStefan Beller, Feb 16, 2017
  39. Junio C HamanoFeb 16, 2017
  40. Stefan BellerFeb 22, 2017
  41. 02/15 lib-submodule-update.sh: do not use ./. as submodule remoteStefan Beller, Feb 16, 2017
  42. 08/15 submodules: introduce check to see whether to touch a submoduleStefan Beller, Feb 16, 2017
  43. Junio C HamanoFeb 16, 2017
  44. Jacob KellerFeb 16, 2017
  45. Jacob KellerFeb 17, 2017
  46. Stefan BellerFeb 21, 2017
  47. 04/15 make is_submodule_populated gentlyStefan Beller, Feb 16, 2017
  48. 09/15 update submodules: move up prepare_submodule_repo_envStefan Beller, Feb 16, 2017
  49. 10/15 update submodules: add submodule_go_from_toStefan Beller, Feb 16, 2017
  50. Junio C HamanoFeb 16, 2017
  51. Stefan BellerFeb 16, 2017
  52. 06/15 update submodules: add submodule config parsingStefan Beller, Feb 16, 2017
  53. Jacob KellerFeb 17, 2017
  54. Stefan BellerFeb 21, 2017
  55. Jacob KellerFeb 21, 2017
  56. 13/15 read-cache: remove_marked_cache_entries to wipe selected submodules.Stefan Beller, Feb 16, 2017
  57. Junio C HamanoFeb 16, 2017
  58. 15/15 builtin/checkout: add --recurse-submodules switchStefan Beller, Feb 16, 2017
  59. 11/15 unpack-trees: pass old oid to verify_clean_submoduleStefan Beller, Feb 16, 2017
  60. Junio C HamanoFeb 16, 2017
  61. 12/15 unpack-trees: check if we can perform the operation for submodulesStefan Beller, Feb 16, 2017
  62. Brandon WilliamsFeb 16, 2017
  63. Junio C HamanoFeb 16, 2017
  64. Jacob KellerFeb 17, 2017
  65. Stefan BellerFeb 21, 2017
  66. Jacob KellerFeb 21, 2017
  67. Stefan BellerFeb 21, 2017
  68. Jacob KellerFeb 22, 2017
  69. 14/15 entry.c: update submodules when interestingStefan Beller, Feb 16, 2017
  70. 01/15 lib-submodule-update.sh: reorder create_lib_submodule_repoStefan Beller, Feb 16, 2017
  71. Junio C HamanoFeb 16, 2017
  72. Jacob KellerFeb 16, 2017
  73. Stefan BellerFeb 16, 2017
  74. Jacob KellerFeb 16, 2017
  75. 00/14 Checkout aware of Submodules!Stefan Beller, Feb 23, 2017
  76. 08/15 submodules: introduce check to see whether to touch a submoduleStefan Beller, Feb 23, 2017
  77. 09/15 update submodules: move up prepare_submodule_repo_envStefan Beller, Feb 23, 2017
  78. 01/15 lib-submodule-update.sh: reorder create_lib_submodule_repoStefan Beller, Feb 23, 2017
  79. 04/15 make is_submodule_populated gentlyStefan Beller, Feb 23, 2017
  80. 03/15 lib-submodule-update.sh: define tests for recursing into submodulesStefan Beller, Feb 23, 2017
  81. 11/15 unpack-trees: pass old oid to verify_clean_submoduleStefan Beller, Feb 23, 2017
  82. 02/15 lib-submodule-update.sh: do not use ./. as submodule remoteStefan Beller, Feb 23, 2017
  83. 06/15 update submodules: add submodule config parsingStefan Beller, Feb 23, 2017
  84. 14/15 entry.c: update submodules when interestingStefan Beller, Feb 23, 2017
  85. 12/15 unpack-trees: check if we can perform the operation for submodulesStefan Beller, Feb 23, 2017
  86. 05/15 connect_work_tree_and_git_dir: safely create leading directoriesStefan Beller, Feb 23, 2017
  87. 07/15 update submodules: add a config option to determine if submodules are updatedStefan Beller, Feb 23, 2017
  88. 10/15 update submodules: add submodule_move_headStefan Beller, Feb 23, 2017
  89. Ramsay JonesFeb 24, 2017
  90. Stefan BellerFeb 24, 2017
  91. 13/15 read-cache, remove_marked_cache_entries: wipe selected submodules.Stefan Beller, Feb 23, 2017
  92. 15/15 builtin/checkout: add --recurse-submodules switchStefan Beller, Feb 23, 2017
  93. Ramsay JonesFeb 24, 2017
  94. Stefan BellerFeb 24, 2017

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.