Re: [PATCH v3 29/42] completion: use __gitcomp_builtin in _git_notes

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

 



On Fri, Feb 9, 2018 at 12:02 PM, Nguyễn Thái Ngọc Duy <pclouds@xxxxxxxxx> wrote:

> diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
> index c7b8b37f19..60127daebf 100644
> --- a/contrib/completion/git-completion.bash
> +++ b/contrib/completion/git-completion.bash

> @@ -1851,15 +1851,17 @@ _git_notes ()
>         add,--reedit-message=*|append,--reedit-message=*)
>                 __git_complete_refs --cur="${cur#*=}"
>                 ;;
> -       add,--*|append,--*)
> -               __gitcomp '--file= --message= --reedit-message=
> -                               --reuse-message='
> +       add,--*)
> +               __gitcomp_builtin notes_add
> +               ;;
> +       append,--*)
> +               __gitcomp_builtin notes_append
>                 ;;
>         copy,--*)
> -               __gitcomp '--stdin'
> +               __gitcomp_builtin notes_copy
>                 ;;
>         prune,--*)
> -               __gitcomp '--dry-run --verbose'
> +               __gitcomp_builtin notes_prune
>                 ;;
>         prune,*)
>                 ;;

This could be simplified to:

  add,--*|append,--*|copy,--*|prune,--*)
        __gitcomp_builtin notes_$subcommand
        ;;

And we could even go one step further:

  *,--*)
        __gitcomp_builtin notes_$subcommand
        ;;

This would have the benefit that if any of the remaining subcommands
learn --options, then they would be completed right away, without the
need to add that subcommand to the case arms.  Case in point is 'git
notes remove', which already accepts two options, but they are not
completed because of the missing 'remove,--*)' case arm.  The same would
also apply to 'git notes merge's options, except that the completion
script completely misses the 'merge' subcommand in the first place
(blame on me, 2a5da75579 (bash: support more 'git notes' subcommands and
their options, 2010-10-10)).

This also applies to the completion functions of other commands with
subcommands ('remote', 'worktree').

The downside is that we would run 'git cmd subcmd
--git-completion-helper' even if a subcommand doesn't use parse options.
I think that's acceptable.




[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