| 76 | } |
| 77 | |
| 78 | static int list_cmds(const char *spec) |
| 79 | { |
| 80 | struct string_list list = STRING_LIST_INIT_DUP; |
| 81 | int nongit; |
| 82 | |
| 83 | /* |
| 84 | * Set up the repository so we can pick up any repo-level config (like |
| 85 | * completion.commands). |
| 86 | */ |
| 87 | setup_git_directory_gently(the_repository, &nongit); |
| 88 | |
| 89 | while (*spec) { |
| 90 | const char *sep = strchrnul(spec, ','); |
| 91 | int len = sep - spec; |
| 92 | |
| 93 | if (match_token(spec, len, "builtins")) |
| 94 | list_builtins(&list, 0, 0); |
| 95 | else if (match_token(spec, len, "main")) |
| 96 | list_all_main_cmds(&list); |
| 97 | else if (match_token(spec, len, "others")) |
| 98 | list_all_other_cmds(&list); |
| 99 | else if (match_token(spec, len, "nohelpers")) |
| 100 | exclude_helpers_from_list(&list); |
| 101 | else if (match_token(spec, len, "alias")) |
| 102 | list_aliases(&list); |
| 103 | else if (match_token(spec, len, "config")) |
| 104 | list_cmds_by_config(&list); |
| 105 | else if (match_token(spec, len, "deprecated")) |
| 106 | list_builtins(&list, DEPRECATED, 0); |
| 107 | else if (len > 5 && !strncmp(spec, "list-", 5)) { |
| 108 | struct strbuf sb = STRBUF_INIT; |
| 109 | |
| 110 | strbuf_add(&sb, spec + 5, len - 5); |
| 111 | list_cmds_by_category(&list, sb.buf); |
| 112 | strbuf_release(&sb); |
| 113 | } |
| 114 | else |
| 115 | die(_("unsupported command listing type '%s'"), spec); |
| 116 | spec += len; |
| 117 | if (*spec == ',') |
| 118 | spec++; |
| 119 | } |
| 120 | for (size_t i = 0; i < list.nr; i++) |
| 121 | puts(list.items[i].string); |
| 122 | string_list_clear(&list, 1); |
| 123 | return 0; |
| 124 | } |
| 125 | |
| 126 | static void commit_pager_choice(void) |
| 127 | { |
no test coverage detected