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

[PATCH v4 06/13] submodule--helper: don't use bitfield indirection for parse_options()

From
Glen Choo <chooglen@google.com>
Date
Mar 5, 2022, 00:13 UTC
Message-ID
<20220305001401.20888-7-chooglen@google.com>
In-Reply-To
<20220305001401.20888-1-chooglen@google.com>
From: Ævar Arnfjörð Bjarmason <avarab@gmail.com>

Do away with the indirection of local variables added in c51f8f94e5b (submodule--helper: run update procedures from C, 2021-08-24).

These were only needed because in C you can't get a pointer to a single bit, so we were using intermediate variables instead.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: Glen Choo <chooglen@google.com>
---
 builtin/submodule--helper.c | 23 ++++++++++-------------
 1 file changed, 10 insertions(+), 13 deletions(-)
diff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c
index b5a2d83029..3832dccae5 100644
--- a/builtin/submodule--helper.c
+++ b/builtin/submodule--helper.c
@@ -2023,10 +2023,10 @@ struct update_data {
 	struct object_id suboid;
 	struct submodule_update_strategy update_strategy;
 	int depth;
-	unsigned int force: 1;
-	unsigned int quiet: 1;
-	unsigned int nofetch: 1;
-	unsigned int just_cloned: 1;
+	unsigned int force;
+	unsigned int quiet;
+	unsigned int nofetch;
+	unsigned int just_cloned;
 };
 #define UPDATE_DATA_INIT { .update_strategy = SUBMODULE_UPDATE_STRATEGY_INIT }
 
@@ -2578,16 +2578,17 @@ static int update_clone(int argc, const char **argv, const char *prefix)
 
 static int run_update_procedure(int argc, const char **argv, const char *prefix)
 {
-	int force = 0, quiet = 0, nofetch = 0, just_cloned = 0;
 	char *prefixed_path, *update = NULL;
 	struct update_data update_data = UPDATE_DATA_INIT;
 
 	struct option options[] = {
-		OPT__QUIET(&quiet, N_("suppress output for update by rebase or merge")),
-		OPT__FORCE(&force, N_("force checkout updates"), 0),
-		OPT_BOOL('N', "no-fetch", &nofetch,
+		OPT__QUIET(&update_data.quiet,
+			   N_("suppress output for update by rebase or merge")),
+		OPT__FORCE(&update_data.force, N_("force checkout updates"),
+			   0),
+		OPT_BOOL('N', "no-fetch", &update_data.nofetch,
 			 N_("don't fetch new objects from the remote site")),
-		OPT_BOOL(0, "just-cloned", &just_cloned,
+		OPT_BOOL(0, "just-cloned", &update_data.just_cloned,
 			 N_("overrides update mode in case the repository is a fresh clone")),
 		OPT_INTEGER(0, "depth", &update_data.depth, N_("depth for shallow fetch")),
 		OPT_STRING(0, "prefix", &prefix,
@@ -2615,10 +2616,6 @@ static int run_update_procedure(int argc, const char **argv, const char *prefix)
 	if (argc != 1)
 		usage_with_options(usage, options);
 
-	update_data.force = !!force;
-	update_data.quiet = !!quiet;
-	update_data.nofetch = !!nofetch;
-	update_data.just_cloned = !!just_cloned;
 	update_data.sm_path = argv[0];
 
 	if (update_data.recursive_prefix)
-- 
2.33.GIT
Previous: Glen ChooNext: Glen Choo
Message 67 of 75 in “submodule: convert parts of 'update' to C”
  1. 00/13 submodule: convert parts of 'update' to CGlen Choo, Mar 1, 2022
  2. 01/13 submodule tests: test for init and update failure outputGlen Choo, Mar 1, 2022
  3. 02/13 submodule--helper: remove update-module-modeGlen Choo, Mar 1, 2022
  4. 04/13 submodule--helper run-update-procedure: remove --suboidGlen Choo, Mar 1, 2022
  5. 03/13 submodule--helper: reorganize code for sh to C conversionGlen Choo, Mar 1, 2022
  6. 05/13 submodule--helper: remove ensure-core-worktreeGlen Choo, Mar 1, 2022
  7. 06/13 submodule--helper: get remote names from any repositoryGlen Choo, Mar 1, 2022
  8. Junio C HamanoMar 1, 2022
  9. Glen ChooMar 1, 2022
  10. 07/13 submodule--helper: don't use bitfield indirection for parse_options()Glen Choo, Mar 1, 2022
  11. 09/13 submodule--helper: refactor get_submodule_displaypath()Glen Choo, Mar 1, 2022
  12. 08/13 submodule--helper run-update-procedure: learn --remoteGlen Choo, Mar 1, 2022
  13. 10/13 submodule--helper: allow setting superprefix for init_submodule()Glen Choo, Mar 1, 2022
  14. 11/13 submodule--helper update-clone: learn --initGlen Choo, Mar 1, 2022
  15. 12/13 submodule update: add tests for --filterGlen Choo, Mar 1, 2022
  16. 13/13 submodule--helper update-clone: check for --filter and --initGlen Choo, Mar 1, 2022
  17. Glen ChooMar 1, 2022
  18. 00/13 submodule: convert parts of 'update' to CGlen Choo, Mar 1, 2022
  19. 01/13 submodule tests: test for init and update failure outputGlen Choo, Mar 1, 2022
  20. 02/13 submodule--helper: remove update-module-modeGlen Choo, Mar 1, 2022
  21. 03/13 submodule--helper: reorganize code for sh to C conversionGlen Choo, Mar 1, 2022
  22. 04/13 submodule--helper run-update-procedure: remove --suboidGlen Choo, Mar 1, 2022
  23. 05/13 submodule--helper: remove ensure-core-worktreeGlen Choo, Mar 1, 2022
  24. 06/13 submodule--helper: get remote names from any repositoryGlen Choo, Mar 1, 2022
  25. Ævar Arnfjörð BjarmasonMar 1, 2022
  26. 07/13 submodule--helper: don't use bitfield indirection for parse_options()Glen Choo, Mar 1, 2022
  27. 08/13 submodule--helper run-update-procedure: learn --remoteGlen Choo, Mar 1, 2022
  28. 09/13 submodule--helper: refactor get_submodule_displaypath()Glen Choo, Mar 1, 2022
  29. Ævar Arnfjörð BjarmasonMar 1, 2022
  30. 10/13 submodule--helper: allow setting superprefix for init_submodule()Glen Choo, Mar 1, 2022
  31. 12/13 submodule update: add tests for --filterGlen Choo, Mar 1, 2022
  32. Ævar Arnfjörð BjarmasonMar 1, 2022
  33. Glen ChooMar 1, 2022
  34. 11/13 submodule--helper update-clone: learn --initGlen Choo, Mar 1, 2022
  35. 13/13 submodule--helper update-clone: check for --filter and --initGlen Choo, Mar 1, 2022
  36. Ævar Arnfjörð BjarmasonMar 1, 2022
  37. Junio C HamanoMar 1, 2022
  38. Glen ChooMar 1, 2022
  39. Ævar Arnfjörð BjarmasonMar 3, 2022
  40. 00/13 submodule: convert parts of 'update' to CGlen Choo, Mar 3, 2022
  41. 01/13 submodule tests: test for init and update failure outputGlen Choo, Mar 3, 2022
  42. 03/13 submodule--helper: reorganize code for sh to C conversionGlen Choo, Mar 3, 2022
  43. 02/13 submodule--helper: remove update-module-modeGlen Choo, Mar 3, 2022
  44. 04/13 submodule--helper run-update-procedure: remove --suboidGlen Choo, Mar 3, 2022
  45. Junio C HamanoMar 3, 2022
  46. 05/13 submodule--helper: remove ensure-core-worktreeGlen Choo, Mar 3, 2022
  47. Junio C HamanoMar 3, 2022
  48. Glen ChooMar 4, 2022
  49. 06/13 submodule--helper: get remote names from any repositoryGlen Choo, Mar 3, 2022
  50. 07/13 submodule--helper: don't use bitfield indirection for parse_options()Glen Choo, Mar 3, 2022
  51. 08/13 submodule--helper run-update-procedure: learn --remoteGlen Choo, Mar 3, 2022
  52. Junio C HamanoMar 3, 2022
  53. Glen ChooMar 4, 2022
  54. 09/13 submodule--helper: refactor get_submodule_displaypath()Glen Choo, Mar 3, 2022
  55. 10/13 submodule--helper: allow setting superprefix for init_submodule()Glen Choo, Mar 3, 2022
  56. 11/13 submodule--helper update-clone: learn --initGlen Choo, Mar 3, 2022
  57. 12/13 submodule update: add tests for --filterGlen Choo, Mar 3, 2022
  58. 13/13 submodule--helper update-clone: check for --filter and --initGlen Choo, Mar 3, 2022
  59. Ævar Arnfjörð BjarmasonMar 3, 2022
  60. Junio C HamanoMar 3, 2022
  61. 00/13 submodule: convert parts of 'update' to CGlen Choo, Mar 5, 2022
  62. 01/13 submodule tests: test for init and update failure outputGlen Choo, Mar 5, 2022
  63. 04/13 submodule--helper run-update-procedure: remove --suboidGlen Choo, Mar 5, 2022
  64. 03/13 submodule--helper: reorganize code for sh to C conversionGlen Choo, Mar 5, 2022
  65. 02/13 submodule--helper: remove update-module-modeGlen Choo, Mar 5, 2022
  66. 05/13 submodule--helper: get remote names from any repositoryGlen Choo, Mar 5, 2022
  67. 06/13 submodule--helper: don't use bitfield indirection for parse_options()Glen Choo, Mar 5, 2022
  68. 07/13 submodule--helper run-update-procedure: learn --remoteGlen Choo, Mar 5, 2022
  69. 08/13 submodule--helper: refactor get_submodule_displaypath()Glen Choo, Mar 5, 2022
  70. 09/13 submodule--helper: allow setting superprefix for init_submodule()Glen Choo, Mar 5, 2022
  71. 10/13 submodule--helper update-clone: learn --initGlen Choo, Mar 5, 2022
  72. 11/13 submodule--helper: remove ensure-core-worktreeGlen Choo, Mar 5, 2022
  73. 13/13 submodule--helper update-clone: check for --filter and --initGlen Choo, Mar 5, 2022
  74. 12/13 submodule update: add tests for --filterGlen Choo, Mar 5, 2022
  75. Junio C HamanoMar 5, 2022

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.