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

Re: [PATCH 05/14] update submodules: add submodule config parsing

From
Junio C Hamano <gitster@pobox.com>
Date
Feb 15, 2017, 18:29 UTC
Message-ID
<xmqqd1ej48am.fsf@gitster.mtv.corp.google.com>
In-Reply-To
<20170215003423.20245-6-sbeller@google.com>
Stefan Beller <sbeller@google.com> writes:
Show 41 quoted lines
> Similar to b33a15b08 (push: add recurseSubmodules config option,
> 2015-11-17) and 027771fcb1 (submodule: allow erroneous values for the
> fetchRecurseSubmodules option, 2015-08-17), we add submodule-config code
> that is later used to parse whether we are interested in updating
> submodules.
>
> We need the `die_on_error` parameter to be able to call this parsing
> function for the config file as well, which if incorrect lets Git die.
>
> As we're just touching the header file, also mark all functions extern.
>
> Signed-off-by: Stefan Beller <sbeller@google.com>
> ---
>  submodule-config.c | 22 ++++++++++++++++++++++
>  submodule-config.h | 17 +++++++++--------
>  2 files changed, 31 insertions(+), 8 deletions(-)
>
> diff --git a/submodule-config.c b/submodule-config.c
> index 93453909cf..93f01c4378 100644
> --- a/submodule-config.c
> +++ b/submodule-config.c
> @@ -234,6 +234,28 @@ int parse_fetch_recurse_submodules_arg(const char *opt, const char *arg)
>  	return parse_fetch_recurse(opt, arg, 1);
>  }
>  
> +static int parse_update_recurse(const char *opt, const char *arg,
> +				int die_on_error)
> +{
> +	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;
> +		if (die_on_error)
> +			die("bad %s argument: %s", opt, arg);
> +		return RECURSE_SUBMODULES_ERROR;
> +	}
> +}

Proliferation of similarly looking config parser made me briefly wonder if they can somehow be shared, but I think it is correct to view that update/fetch/push have conceptually different set of allowed modes, whose names happen to overlap, so keeping them separate like this patch does (and its predecessors did to take us into the shape of the current code) makes sense, at least to me.

Previous: Stefan BellerNext: Stefan Beller
Message 12 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.