Re: [PATCH v4/wip 08/12] git: support --list-cmds=<category>

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Apr 25, 2018 at 12:31 PM, Nguyễn Thái Ngọc Duy
<pclouds@xxxxxxxxx> wrote:
> This allows us to select any group of commands by a category defined
> in command-list.txt. This is an internal/hidden option so we don't
> have to be picky about the category name or worried about exposing too
> much.
>
> This will be used later by git-completion.bash to retrieve certain
> command groups.
>
> Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@xxxxxxxxx>
> ---
> diff --git a/help.c b/help.c
> @@ -305,6 +305,25 @@ void list_all_cmds(void)
> +void list_cmds_by_category(const char *cat)
> +{
> +       int i;
> +       int cat_id = 0;

Should 'cat_id' be unsigned...

> +
> +       for (i = 0; category_names[i]; i++) {
> +               if (!strcmp(cat, category_names[i])) {
> +                       cat_id = 1 << i;

...since you're shifting it here?

> +                       break;
> +               }
> +       }
> +       if (!cat_id)
> +               die("unsupported command listing type '%s'", cat);
> +
> +       for (i = 0; command_list[i].name; i++)
> +               if (command_list[i].category & cat_id)
> +                       puts(command_list[i].name);
> +}




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux