completion: add and use --list-cmds=nohelpers
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>maint
parent
65b5f9483e
commit
e11dca10cf
|
@ -169,7 +169,8 @@ foo.bar= ...`) sets `foo.bar` to the empty string which `git config
|
||||||
groups are: builtins, parseopt (builtin commands that use
|
groups are: builtins, parseopt (builtin commands that use
|
||||||
parse-options), main (all commands in libexec directory),
|
parse-options), main (all commands in libexec directory),
|
||||||
others (all other commands in `$PATH` that have git- prefix),
|
others (all other commands in `$PATH` that have git- prefix),
|
||||||
list-<category> (see categories in command-list.txt)
|
list-<category> (see categories in command-list.txt),
|
||||||
|
nohelpers (exclude helper commands).
|
||||||
|
|
||||||
GIT COMMANDS
|
GIT COMMANDS
|
||||||
------------
|
------------
|
||||||
|
|
|
@ -843,7 +843,7 @@ __git_commands () {
|
||||||
then
|
then
|
||||||
printf "%s" "$GIT_TESTING_PORCELAIN_COMMAND_LIST"
|
printf "%s" "$GIT_TESTING_PORCELAIN_COMMAND_LIST"
|
||||||
else
|
else
|
||||||
git --list-cmds=list-mainporcelain,others,list-complete
|
git --list-cmds=list-mainporcelain,others,nohelpers,list-complete
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
all)
|
all)
|
||||||
|
@ -851,27 +851,15 @@ __git_commands () {
|
||||||
then
|
then
|
||||||
printf "%s" "$GIT_TESTING_ALL_COMMAND_LIST"
|
printf "%s" "$GIT_TESTING_ALL_COMMAND_LIST"
|
||||||
else
|
else
|
||||||
git --list-cmds=main,others
|
git --list-cmds=main,others,nohelpers
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
|
|
||||||
__git_list_commands ()
|
|
||||||
{
|
|
||||||
local i IFS=" "$'\n'
|
|
||||||
for i in $(__git_commands $1)
|
|
||||||
do
|
|
||||||
case $i in
|
|
||||||
*--*) : helper pattern;;
|
|
||||||
*) echo $i;;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
}
|
|
||||||
|
|
||||||
__git_list_all_commands ()
|
__git_list_all_commands ()
|
||||||
{
|
{
|
||||||
__git_list_commands all
|
__git_commands all
|
||||||
}
|
}
|
||||||
|
|
||||||
__git_all_commands=
|
__git_all_commands=
|
||||||
|
@ -883,7 +871,7 @@ __git_compute_all_commands ()
|
||||||
|
|
||||||
__git_list_porcelain_commands ()
|
__git_list_porcelain_commands ()
|
||||||
{
|
{
|
||||||
__git_list_commands porcelain
|
__git_commands porcelain
|
||||||
}
|
}
|
||||||
|
|
||||||
__git_porcelain_commands=
|
__git_porcelain_commands=
|
||||||
|
|
14
git.c
14
git.c
|
@ -39,6 +39,18 @@ static int use_pager = -1;
|
||||||
|
|
||||||
static void list_builtins(struct string_list *list, unsigned int exclude_option);
|
static void list_builtins(struct string_list *list, unsigned int exclude_option);
|
||||||
|
|
||||||
|
static void exclude_helpers_from_list(struct string_list *list)
|
||||||
|
{
|
||||||
|
int i = 0;
|
||||||
|
|
||||||
|
while (i < list->nr) {
|
||||||
|
if (strstr(list->items[i].string, "--"))
|
||||||
|
unsorted_string_list_delete_item(list, i, 0);
|
||||||
|
else
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static int match_token(const char *spec, int len, const char *token)
|
static int match_token(const char *spec, int len, const char *token)
|
||||||
{
|
{
|
||||||
int token_len = strlen(token);
|
int token_len = strlen(token);
|
||||||
|
@ -61,6 +73,8 @@ static int list_cmds(const char *spec)
|
||||||
list_all_main_cmds(&list);
|
list_all_main_cmds(&list);
|
||||||
else if (match_token(spec, len, "others"))
|
else if (match_token(spec, len, "others"))
|
||||||
list_all_other_cmds(&list);
|
list_all_other_cmds(&list);
|
||||||
|
else if (match_token(spec, len, "nohelpers"))
|
||||||
|
exclude_helpers_from_list(&list);
|
||||||
else if (len > 5 && !strncmp(spec, "list-", 5)) {
|
else if (len > 5 && !strncmp(spec, "list-", 5)) {
|
||||||
struct strbuf sb = STRBUF_INIT;
|
struct strbuf sb = STRBUF_INIT;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue