@@ -98,7 +98,8 @@ static int cmd_name_cmp(const void *elem1, const void *elem2)
98
98
return strcmp (e1 -> name , e2 -> name );
99
99
}
100
100
101
- static void print_cmd_by_category (const struct category_description * catdesc )
101
+ static void print_cmd_by_category (const struct category_description * catdesc ,
102
+ int * longest_p )
102
103
{
103
104
struct cmdname_help * cmds ;
104
105
int longest = 0 ;
@@ -124,6 +125,8 @@ static void print_cmd_by_category(const struct category_description *catdesc)
124
125
print_command_list (cmds , mask , longest );
125
126
}
126
127
free (cmds );
128
+ if (longest_p )
129
+ * longest_p = longest ;
127
130
}
128
131
129
132
void add_cmdname (struct cmdnames * cmds , const char * name , int len )
@@ -307,7 +310,7 @@ void list_commands(unsigned int colopts,
307
310
void list_common_cmds_help (void )
308
311
{
309
312
puts (_ ("These are common Git commands used in various situations:" ));
310
- print_cmd_by_category (common_categories );
313
+ print_cmd_by_category (common_categories , NULL );
311
314
}
312
315
313
316
void list_all_main_cmds (struct string_list * list )
@@ -405,7 +408,7 @@ void list_common_guides_help(void)
405
408
{ CAT_guide , N_ ("The common Git guides are:" ) },
406
409
{ 0 , NULL }
407
410
};
408
- print_cmd_by_category (catdesc );
411
+ print_cmd_by_category (catdesc , NULL );
409
412
putchar ('\n' );
410
413
}
411
414
@@ -494,9 +497,48 @@ void list_config_help(int for_human)
494
497
string_list_clear (& keys , 0 );
495
498
}
496
499
500
+ static int get_alias (const char * var , const char * value , void * data )
501
+ {
502
+ struct string_list * list = data ;
503
+
504
+ if (skip_prefix (var , "alias." , & var ))
505
+ string_list_append (list , var )-> util = xstrdup (value );
506
+
507
+ return 0 ;
508
+ }
509
+
497
510
void list_all_cmds_help (void )
498
511
{
499
- print_cmd_by_category (main_categories );
512
+ struct string_list others = STRING_LIST_INIT_DUP ;
513
+ struct string_list alias_list = STRING_LIST_INIT_DUP ;
514
+ struct cmdname_help * aliases ;
515
+ int i , longest ;
516
+
517
+ printf_ln (_ ("See 'git help <command>' to read about a specific subcommand" ));
518
+ print_cmd_by_category (main_categories , & longest );
519
+
520
+ list_all_other_cmds (& others );
521
+ if (others .nr )
522
+ printf ("\n%s\n" , _ ("External commands" ));
523
+ for (i = 0 ; i < others .nr ; i ++ )
524
+ printf (" %s\n" , others .items [i ].string );
525
+ string_list_clear (& others , 0 );
526
+
527
+ git_config (get_alias , & alias_list );
528
+ string_list_sort (& alias_list );
529
+ if (alias_list .nr ) {
530
+ printf ("\n%s\n" , _ ("Command aliases" ));
531
+ ALLOC_ARRAY (aliases , alias_list .nr + 1 );
532
+ for (i = 0 ; i < alias_list .nr ; i ++ ) {
533
+ aliases [i ].name = alias_list .items [i ].string ;
534
+ aliases [i ].help = alias_list .items [i ].util ;
535
+ aliases [i ].category = 1 ;
536
+ }
537
+ aliases [alias_list .nr ].name = NULL ;
538
+ print_command_list (aliases , 1 , longest );
539
+ free (aliases );
540
+ }
541
+ string_list_clear (& alias_list , 1 );
500
542
}
501
543
502
544
int is_in_cmdlist (struct cmdnames * c , const char * s )
0 commit comments