Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/help.c
diff options
context:
space:
mode:
authorNguyễn Thái Ngọc Duy <pclouds@gmail.com>2018-05-20 21:39:59 +0300
committerJunio C Hamano <gitster@pobox.com>2018-05-21 07:23:14 +0300
commit6bb2dc0b9472a84c7d17ee93bda28a7c1c97d415 (patch)
treea7e2eb1915f25ed24190aaacbf2e26e9146c8737 /help.c
parente5d7a61953c236fbc468bc1bb01383766d2cb55b (diff)
completion: implement and use --list-cmds=main,others
This is part of the effort to break down and provide commands by category in machine-readable form. This could be helpful later on when completion script switches to use --list-cmds for selecting completable commands. It would be much easier for the user to choose to complete _all_ commands instead of the default selection by passing different values to --list-cmds in git-completino.bash. While at there, replace "git help -a" in git-completion.bash with --list-cmds since it's better suited for this task. 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.c32
1 files changed, 32 insertions, 0 deletions
diff --git a/help.c b/help.c
index 2d6a3157f8..d5ce9dfcbb 100644
--- a/help.c
+++ b/help.c
@@ -297,6 +297,38 @@ void list_common_cmds_help(void)
print_cmd_by_category(common_categories);
}
+void list_all_main_cmds(struct string_list *list)
+{
+ struct cmdnames main_cmds, other_cmds;
+ int i;
+
+ memset(&main_cmds, 0, sizeof(main_cmds));
+ memset(&other_cmds, 0, sizeof(other_cmds));
+ load_command_list("git-", &main_cmds, &other_cmds);
+
+ for (i = 0; i < main_cmds.cnt; i++)
+ string_list_append(list, main_cmds.names[i]->name);
+
+ clean_cmdnames(&main_cmds);
+ clean_cmdnames(&other_cmds);
+}
+
+void list_all_other_cmds(struct string_list *list)
+{
+ struct cmdnames main_cmds, other_cmds;
+ int i;
+
+ memset(&main_cmds, 0, sizeof(main_cmds));
+ memset(&other_cmds, 0, sizeof(other_cmds));
+ load_command_list("git-", &main_cmds, &other_cmds);
+
+ for (i = 0; i < other_cmds.cnt; i++)
+ string_list_append(list, other_cmds.names[i]->name);
+
+ clean_cmdnames(&main_cmds);
+ clean_cmdnames(&other_cmds);
+}
+
int is_in_cmdlist(struct cmdnames *c, const char *s)
{
int i;