Re: [PATCH v3 29/42] completion: use __gitcomp_builtin in _git_notes
- From
Duy Nguyen <pclouds@gmail.com>
- Date
- Feb 23, 2018, 10:33 UTC
- Message-ID
- <CACsJy8CQJViiDVuEXH-zkY_yX5AUahJCCshX=jedHhVvfpMUiA@mail.gmail.com>
- In-Reply-To
- <CAM0VKjmJwDUv4gTQ+22SgfX+=PahXRPeP=774hV7mxxm3nXiYg@mail.gmail.com>
On Wed, Feb 14, 2018 at 9:29 PM, SZEDER Gábor <szeder.dev@gmail.com> wrote:
Show 46 quoted lines
> On Fri, Feb 9, 2018 at 12:02 PM, Nguyễn Thái Ngọc Duy <pclouds@gmail.com> 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.You read my mind ;-) We won't do this in this series though (but I will simplify the code as suggested). parse-options.c does not have any concept about these subcommands. So a bit more work and can (and will) be done separately.
-- Duy