help.c: split up list_all_cmds_help() function
Split up the listing of commands and aliases from list_all_cmds_help(). This will make a subsequent functional change smaller. Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Ævar Arnfjörð Bjarmason committed
Feb 21, 2022 at 20:38 UTC
6fb427abbb06236546c0d5b873e580b0a6fdb414
1 file changed
+20
-7
help.c
+20
-7
@@ -433,15 +433,10 @@ static int get_alias(const char *var, const char *value, void *data)
433
return 0;
434
}
435
436
-void list_all_cmds_help(void)
436
+static void list_all_cmds_help_external_commands(void)
437
{
438
struct string_list others = STRING_LIST_INIT_DUP;
439
- struct string_list alias_list = STRING_LIST_INIT_DUP;
440
- struct cmdname_help *aliases;
441
- int i, longest;
442
-
443
- puts(_("See 'git help <command>' to read about a specific subcommand"));
444
- print_cmd_by_category(main_categories, &longest);
439
+ int i;
440
441
list_all_other_cmds(&others);
442
if (others.nr)
@@ -449,6 +444,13 @@ void list_all_cmds_help(void)
444
for (i = 0; i < others.nr; i++)
445
printf(" %s\n", others.items[i].string);
446
string_list_clear(&others, 0);
447
+}
448
+
449
+static void list_all_cmds_help_aliases(int longest)
450
+{
451
+ struct string_list alias_list = STRING_LIST_INIT_DUP;
452
+ struct cmdname_help *aliases;
453
+ int i;
454
455
git_config(get_alias, &alias_list);
456
string_list_sort(&alias_list);
@@ -474,6 +476,17 @@ void list_all_cmds_help(void)
476
string_list_clear(&alias_list, 1);
477
}
478
479
+void list_all_cmds_help(void)
480
+{
481
+ int longest;
482
+
483
+ puts(_("See 'git help <command>' to read about a specific subcommand"));
484
+ print_cmd_by_category(main_categories, &longest);
485
+
486
+ list_all_cmds_help_external_commands();
487
+ list_all_cmds_help_aliases(longest);
488
+}
489
+
490
int is_in_cmdlist(struct cmdnames *c, const char *s)
491
{
492
int i;