submodule--helper style: don't separate declared variables with \n\n

The usual style in the codebase is to separate declared variables with a single newline, not two, let's adjust this code to conform to that. This makes the eventual addition of various "int ret" variables more consistent. In doing this the comment added in 2964d6e5e1e (submodule: port subcommand 'set-branch' from shell to C, 2020-06-02) might become ambiguous to some, although it should be clear what it's referring to, let's move it above the 'OPT_NOOP_NOARG('q', "quiet")' to make that clearer. Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Reviewed-by: Glen Choo <chooglen@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Ævar Arnfjörð Bjarmason committed Sep 1, 2022 at 01:17 UTC e2d5c886bfb9ac21368786d9330a3e395f21ac5b
1 file changed +5 -28
builtin/submodule--helper.c
+5 -28
@@ -368,14 +368,12 @@ static int module_foreach(int argc, const char **argv, const char *prefix)
368 struct foreach_cb info = FOREACH_CB_INIT;
369 struct pathspec pathspec;
370 struct module_list list = MODULE_LIST_INIT;
371 -
371 struct option module_foreach_options[] = {
372 OPT__QUIET(&info.quiet, N_("suppress output of entering each submodule command")),
373 OPT_BOOL(0, "recursive", &info.recursive,
374 N_("recurse into nested submodules")),
375 OPT_END()
376 };
378 -
377 const char *const git_submodule_helper_usage[] = {
378 N_("git submodule foreach [--quiet] [--recursive] [--] <command>"),
379 NULL
@@ -504,12 +502,10 @@ static int module_init(int argc, const char **argv, const char *prefix)
502 struct pathspec pathspec;
503 struct module_list list = MODULE_LIST_INIT;
504 int quiet = 0;
507 -
505 struct option module_init_options[] = {
506 OPT__QUIET(&quiet, N_("suppress output for initializing a submodule")),
507 OPT_END()
508 };
512 -
509 const char *const git_submodule_helper_usage[] = {
510 N_("git submodule init [<options>] [<path>]"),
511 NULL
@@ -682,14 +678,12 @@ static int module_status(int argc, const char **argv, const char *prefix)
678 struct pathspec pathspec;
679 struct module_list list = MODULE_LIST_INIT;
680 int quiet = 0;
685 -
681 struct option module_status_options[] = {
682 OPT__QUIET(&quiet, N_("suppress submodule status output")),
683 OPT_BIT(0, "cached", &info.flags, N_("use commit stored in the index instead of the one stored in the submodule HEAD"), OPT_CACHED),
684 OPT_BIT(0, "recursive", &info.flags, N_("recurse into nested submodules"), OPT_RECURSIVE),
685 OPT_END()
686 };
692 -
687 const char *const git_submodule_helper_usage[] = {
688 N_("git submodule status [--quiet] [--cached] [--recursive] [<path>...]"),
689 NULL
@@ -1082,7 +1076,6 @@ static int module_summary(int argc, const char **argv, const char *prefix)
1076 enum diff_cmd diff_cmd = DIFF_INDEX;
1077 struct object_id head_oid;
1078 int ret;
1085 -
1079 struct option module_summary_options[] = {
1080 OPT_BOOL(0, "cached", &cached,
1081 N_("use the commit stored in the index instead of the submodule HEAD")),
@@ -1094,7 +1087,6 @@ static int module_summary(int argc, const char **argv, const char *prefix)
1087 N_("limit the summary size")),
1088 OPT_END()
1089 };
1097 -
1090 const char *const git_submodule_helper_usage[] = {
1091 N_("git submodule summary [<options>] [<commit>] [--] [<path>]"),
1092 NULL
@@ -1251,14 +1243,12 @@ static int module_sync(int argc, const char **argv, const char *prefix)
1243 struct module_list list = MODULE_LIST_INIT;
1244 int quiet = 0;
1245 int recursive = 0;
1254 -
1246 struct option module_sync_options[] = {
1247 OPT__QUIET(&quiet, N_("suppress output of synchronizing submodule url")),
1248 OPT_BOOL(0, "recursive", &recursive,
1249 N_("recurse into nested submodules")),
1250 OPT_END()
1251 };
1261 -
1252 const char *const git_submodule_helper_usage[] = {
1253 N_("git submodule sync [--quiet] [--recursive] [<path>]"),
1254 NULL
@@ -1390,14 +1380,12 @@ static int module_deinit(int argc, const char **argv, const char *prefix)
1380 int quiet = 0;
1381 int force = 0;
1382 int all = 0;
1393 -
1383 struct option module_deinit_options[] = {
1384 OPT__QUIET(&quiet, N_("suppress submodule status output")),
1385 OPT__FORCE(&force, N_("remove submodule working trees even if they contain local changes"), 0),
1386 OPT_BOOL(0, "all", &all, N_("unregister all submodules")),
1387 OPT_END()
1388 };
1400 -
1389 const char *const git_submodule_helper_usage[] = {
1390 N_("git submodule deinit [--quiet] [-f | --force] [--all | [--] [<path>...]]"),
1391 NULL
@@ -1666,7 +1654,6 @@ static int module_clone(int argc, const char **argv, const char *prefix)
1654 int dissociate = 0, quiet = 0, progress = 0, require_init = 0;
1655 struct module_clone_data clone_data = MODULE_CLONE_DATA_INIT;
1656 struct list_objects_filter_options filter_options;
1669 -
1657 struct option module_clone_options[] = {
1658 OPT_STRING(0, "prefix", &clone_data.prefix,
1659 N_("path"),
@@ -1698,7 +1685,6 @@ static int module_clone(int argc, const char **argv, const char *prefix)
1685 OPT_PARSE_LIST_OBJECTS_FILTER(&filter_options),
1686 OPT_END()
1687 };
1701 -
1688 const char *const git_submodule_helper_usage[] = {
1689 N_("git submodule--helper clone [--prefix=<path>] [--quiet] "
1690 "[--reference <repository>] [--name <name>] [--depth <depth>] "
@@ -2486,7 +2472,6 @@ static int module_update(int argc, const char **argv, const char *prefix)
2472 struct update_data opt = UPDATE_DATA_INIT;
2473 struct list_objects_filter_options filter_options;
2474 int ret;
2489 -
2475 struct option module_update_options[] = {
2476 OPT__FORCE(&opt.force, N_("force checkout updates"), 0),
2477 OPT_BOOL(0, "init", &opt.init,
@@ -2530,7 +2515,6 @@ static int module_update(int argc, const char **argv, const char *prefix)
2515 OPT_PARSE_LIST_OBJECTS_FILTER(&filter_options),
2516 OPT_END()
2517 };
2533 -
2518 const char *const git_submodule_helper_usage[] = {
2519 N_("git submodule [--quiet] update"
2520 " [--init [--filter=<filter-spec>]] [--remote]"
@@ -2679,7 +2663,6 @@ static int absorb_git_dirs(int argc, const char **argv, const char *prefix)
2663 struct pathspec pathspec;
2664 struct module_list list = MODULE_LIST_INIT;
2665 unsigned flags = ABSORB_GITDIR_RECURSE_SUBMODULES;
2682 -
2666 struct option embed_gitdir_options[] = {
2667 OPT_STRING(0, "prefix", &prefix,
2668 N_("path"),
@@ -2688,7 +2671,6 @@ static int absorb_git_dirs(int argc, const char **argv, const char *prefix)
2671 ABSORB_GITDIR_RECURSE_SUBMODULES),
2672 OPT_END()
2673 };
2691 -
2674 const char *const git_submodule_helper_usage[] = {
2675 N_("git submodule absorbgitdirs [<options>] [<path>...]"),
2676 NULL
@@ -2712,7 +2694,6 @@ static int module_config(int argc, const char **argv, const char *prefix)
2694 CHECK_WRITEABLE = 1,
2695 DO_UNSET = 2
2696 } command = 0;
2715 -
2697 struct option module_config_options[] = {
2698 OPT_CMDMODE(0, "check-writeable", &command,
2699 N_("check if it is safe to write to the .gitmodules file"),
@@ -2758,7 +2739,6 @@ static int module_set_url(int argc, const char **argv, const char *prefix)
2739 const char *newurl;
2740 const char *path;
2741 char *config_name;
2761 -
2742 struct option options[] = {
2743 OPT__QUIET(&quiet, N_("suppress output for setting url of a submodule")),
2744 OPT_END()
@@ -2789,13 +2769,13 @@ static int module_set_branch(int argc, const char **argv, const char *prefix)
2769 const char *opt_branch = NULL;
2770 const char *path;
2771 char *config_name;
2792 -
2793 - /*
2794 - * We accept the `quiet` option for uniformity across subcommands,
2795 - * though there is nothing to make less verbose in this subcommand.
2796 - */
2772 struct option options[] = {
2773 + /*
2774 + * We accept the `quiet` option for uniformity across subcommands,
2775 + * though there is nothing to make less verbose in this subcommand.
2776 + */
2777 OPT_NOOP_NOARG('q', "quiet"),
2778 +
2779 OPT_BOOL('d', "default", &opt_default,
2780 N_("set the default tracking branch to master")),
2781 OPT_STRING('b', "branch", &opt_branch, N_("branch"),
@@ -2830,7 +2810,6 @@ static int module_create_branch(int argc, const char **argv, const char *prefix)
2810 {
2811 enum branch_track track;
2812 int quiet = 0, force = 0, reflog = 0, dry_run = 0;
2833 -
2813 struct option options[] = {
2814 OPT__QUIET(&quiet, N_("print only error messages")),
2815 OPT__FORCE(&force, N_("force creation"), 0),
@@ -3129,7 +3108,6 @@ static int module_add(int argc, const char **argv, const char *prefix)
3108 int force = 0, quiet = 0, progress = 0, dissociate = 0;
3109 struct add_data add_data = ADD_DATA_INIT;
3110 char *to_free = NULL;
3132 -
3111 struct option options[] = {
3112 OPT_STRING('b', "branch", &add_data.branch, N_("branch"),
3113 N_("branch of repository to add as submodule")),
@@ -3146,7 +3124,6 @@ static int module_add(int argc, const char **argv, const char *prefix)
3124 OPT_INTEGER(0, "depth", &add_data.depth, N_("depth for shallow clones")),
3125 OPT_END()
3126 };
3149 -
3127 const char *const usage[] = {
3128 N_("git submodule add [<options>] [--] <repository> [<path>]"),
3129 NULL