git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH 2/2] completion: simplify _git_notes

From
SZEDER Gábor <szeder.dev@gmail.com>
Date
Mar 3, 2018, 12:32 UTC
Message-ID
<CAM0VKj=Kgw5Yh50HjdoD_OteF0n8C-pJo9z09x6jEPQt1w+96A@mail.gmail.com>
In-Reply-To
<20180303092307.3796-3-pclouds@gmail.com>
On Sat, Mar 3, 2018 at 10:23 AM, Nguyễn Thái Ngọc Duy <pclouds@gmail.com> wrote:
Show 5 quoted lines
> This also adds completion for 'git notes remove' with two options:
> --ignore-missing and --stdin.
>
> For some strange reason, 'git notes undefined --<tab>' completes --ref
> without even running --git-completion-helper.

There is nothing strange about it. _git_notes() first looks for the presence of any subcommands on the command line, and if it doesn't find any, it will list 'git notes's subcommands and options for completion. And it does so by running '__gitcomp "$subcommands --ref"'

> But since this is an error
> case (and we're not doing anything destructive, it's probably ok for now)
I agree; and it matches the behaviour before the patch.
Show 34 quoted lines
> Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
> ---
>  contrib/completion/git-completion.bash | 15 ++-------------
>  1 file changed, 2 insertions(+), 13 deletions(-)
>
> diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
> index c310b241d3..ab80f4e6e8 100644
> --- a/contrib/completion/git-completion.bash
> +++ b/contrib/completion/git-completion.bash
> @@ -1836,19 +1836,8 @@ _git_notes ()
>         add,--reedit-message=*|append,--reedit-message=*)
>                 __git_complete_refs --cur="${cur#*=}"
>                 ;;
> -       add,--*)
> -               __gitcomp_builtin notes_add
> -               ;;
> -       append,--*)
> -               __gitcomp_builtin notes_append
> -               ;;
> -       copy,--*)
> -               __gitcomp_builtin notes_copy
> -               ;;
> -       prune,--*)
> -               __gitcomp_builtin notes_prune
> -               ;;
> -       prune,*)
> +       *,--*)
> +               __gitcomp_builtin notes_$subcommand
>                 ;;
>         *)
>                 case "$prev" in
> --
> 2.16.1.435.g8f24da2e1a
>
Previous: Nguyễn Thái Ngọc DuyNext: SZEDER Gábor
Message 6 of 15 in “nd/parseopt-completion fixups”
  1. 0/2 nd/parseopt-completion fixupsNguyễn Thái Ngọc Duy, Mar 3, 2018
  2. 1/2 completion: don't set PARSE_OPT_NOCOMPLETE on --rerere-autoupdateNguyễn Thái Ngọc Duy, Mar 3, 2018
  3. Eric SunshineMar 3, 2018
  4. Phillip WoodMar 6, 2018
  5. 2/2 completion: simplify _git_notesNguyễn Thái Ngọc Duy, Mar 3, 2018
  6. SZEDER GáborMar 3, 2018
  7. SZEDER GáborMar 3, 2018
  8. Junio C HamanoMar 6, 2018
  9. SZEDER GáborMar 7, 2018
  10. Junio C HamanoMar 7, 2018
  11. 0/4 nd/parseopt-completion fixupsNguyễn Thái Ngọc Duy, Mar 7, 2018
  12. 1/4 completion: don't set PARSE_OPT_NOCOMPLETE on --rerere-autoupdateNguyễn Thái Ngọc Duy, Mar 7, 2018
  13. 2/4 completion: simplify _git_notesNguyễn Thái Ngọc Duy, Mar 7, 2018
  14. 3/4 completion: complete --{reuse,reedit}-message= for all notes subcmdsNguyễn Thái Ngọc Duy, Mar 7, 2018
  15. 4/4 completion: more subcommands in _git_notes()Nguyễn Thái Ngọc Duy, Mar 7, 2018

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.