File tree Expand file tree Collapse file tree 5 files changed +51
-1
lines changed Expand file tree Collapse file tree 5 files changed +51
-1
lines changed Original file line number Diff line number Diff line change @@ -168,7 +168,8 @@ foo.bar= ...`) sets `foo.bar` to the empty string which `git config
168
168
option and may change or be removed in the future. Supported
169
169
groups are: builtins, parseopt (builtin commands that use
170
170
parse-options), main (all commands in libexec directory),
171
- others (all other commands in `$PATH` that have git- prefix).
171
+ others (all other commands in `$PATH` that have git- prefix),
172
+ list-<category> (see categories in command-list.txt)
172
173
173
174
GIT COMMANDS
174
175
------------
Original file line number Diff line number Diff line change @@ -45,6 +45,21 @@ define_categories () {
45
45
test " $bit " -gt 32 && die " Urgh.. too many categories?"
46
46
}
47
47
48
+ define_category_names () {
49
+ echo
50
+ echo " /* Category names */"
51
+ echo " static const char *category_names[] = {"
52
+ bit=0
53
+ category_list " $1 " |
54
+ while read cat
55
+ do
56
+ echo " \" $cat \" , /* (1UL << $bit ) */"
57
+ bit=$(( $bit + 1 ))
58
+ done
59
+ echo " NULL"
60
+ echo " };"
61
+ }
62
+
48
63
print_command_list () {
49
64
echo " static struct cmdname_help command_list[] = {"
50
65
@@ -70,4 +85,6 @@ struct cmdname_help {
70
85
"
71
86
define_categories " $1 "
72
87
echo
88
+ define_category_names " $1 "
89
+ echo
73
90
print_command_list " $1 "
Original file line number Diff line number Diff line change @@ -60,6 +60,13 @@ static int list_cmds(const char *spec)
60
60
list_all_main_cmds (& list );
61
61
else if (match_token (spec , len , "others" ))
62
62
list_all_other_cmds (& list );
63
+ else if (len > 5 && !strncmp (spec , "list-" , 5 )) {
64
+ struct strbuf sb = STRBUF_INIT ;
65
+
66
+ strbuf_add (& sb , spec + 5 , len - 5 );
67
+ list_cmds_by_category (& list , sb .buf );
68
+ strbuf_release (& sb );
69
+ }
63
70
else
64
71
die (_ ("unsupported command listing type '%s'" ), spec );
65
72
spec += len ;
Original file line number Diff line number Diff line change @@ -329,6 +329,29 @@ void list_all_other_cmds(struct string_list *list)
329
329
clean_cmdnames (& other_cmds );
330
330
}
331
331
332
+ void list_cmds_by_category (struct string_list * list ,
333
+ const char * cat )
334
+ {
335
+ int i , n = ARRAY_SIZE (command_list );
336
+ uint32_t cat_id = 0 ;
337
+
338
+ for (i = 0 ; category_names [i ]; i ++ ) {
339
+ if (!strcmp (cat , category_names [i ])) {
340
+ cat_id = 1UL << i ;
341
+ break ;
342
+ }
343
+ }
344
+ if (!cat_id )
345
+ die (_ ("unsupported command listing type '%s'" ), cat );
346
+
347
+ for (i = 0 ; i < n ; i ++ ) {
348
+ struct cmdname_help * cmd = command_list + i ;
349
+
350
+ if (cmd -> category & cat_id )
351
+ string_list_append (list , drop_prefix (cmd -> name ));
352
+ }
353
+ }
354
+
332
355
int is_in_cmdlist (struct cmdnames * c , const char * s )
333
356
{
334
357
int i ;
Original file line number Diff line number Diff line change @@ -21,6 +21,8 @@ static inline void mput_char(char c, unsigned int num)
21
21
extern void list_common_cmds_help (void );
22
22
extern void list_all_main_cmds (struct string_list * list );
23
23
extern void list_all_other_cmds (struct string_list * list );
24
+ extern void list_cmds_by_category (struct string_list * list ,
25
+ const char * category );
24
26
extern const char * help_unknown_cmd (const char * cmd );
25
27
extern void load_command_list (const char * prefix ,
26
28
struct cmdnames * main_cmds ,
You can’t perform that action at this time.
0 commit comments