summaryrefslogtreecommitdiff
path: root/help.c
diff options
context:
space:
mode:
authorNguyễn Thái Ngọc Duy <pclouds@gmail.com>2018-05-20 20:40:02 +0200
committerJunio C Hamano <gitster@pobox.com>2018-05-21 13:23:14 +0900
commit1b81d8cb19d8da6d865b7fca5a095dd5fec8d209 (patch)
treef2e9df53830c97ecdc6c77e942feda9816eb9166 /help.c
parent63eae83f8f301a1052cdde254b84f5da00e7b9b6 (diff)
downloadgit-1b81d8cb19d8da6d865b7fca5a095dd5fec8d209.tar.gz
help: use command-list.txt for the source of guides
The help command currently hard codes the list of guides and their summary in C. Let's move this list to command-list.txt. This lets us extract summary lines from Documentation/git*.txt. This also potentially lets us list guides in git.txt, but I'll leave that for now. Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'help.c')
-rw-r--r--help.c21
1 files changed, 17 insertions, 4 deletions
diff --git a/help.c b/help.c
index c7df1d2338..23924dd300 100644
--- a/help.c
+++ b/help.c
@@ -39,12 +39,14 @@ static struct category_description main_categories[] = {
{ 0, NULL }
};
-static const char *drop_prefix(const char *name)
+static const char *drop_prefix(const char *name, uint32_t category)
{
const char *new_name;
if (skip_prefix(name, "git-", &new_name))
return new_name;
+ if (category == CAT_guide && skip_prefix(name, "git", &new_name))
+ return new_name;
return name;
}
@@ -66,7 +68,7 @@ static void extract_cmds(struct cmdname_help **p_cmds, uint32_t mask)
continue;
cmds[nr] = *cmd;
- cmds[nr].name = drop_prefix(cmd->name);
+ cmds[nr].name = drop_prefix(cmd->name, cmd->category);
nr++;
}
@@ -358,11 +360,22 @@ void list_cmds_by_category(struct string_list *list,
for (i = 0; i < n; i++) {
struct cmdname_help *cmd = command_list + i;
- if (cmd->category & cat_id)
- string_list_append(list, drop_prefix(cmd->name));
+ if (!(cmd->category & cat_id))
+ continue;
+ string_list_append(list, drop_prefix(cmd->name, cmd->category));
}
}
+void list_common_guides_help(void)
+{
+ struct category_description catdesc[] = {
+ { CAT_guide, N_("The common Git guides are:") },
+ { 0, NULL }
+ };
+ print_cmd_by_category(catdesc);
+ putchar('\n');
+}
+
void list_all_cmds_help(void)
{
print_cmd_by_category(main_categories);