Thread (115 messages) 115 messages, 4 authors, 2018-12-11

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

From: Duy Nguyen <hidden>
Date: 2018-02-23 10:33:55

On Wed, Feb 14, 2018 at 9:29 PM, SZEDER Gábor [off-list ref] wrote:
On Fri, Feb 9, 2018 at 12:02 PM, Nguyễn Thái Ngọc Duy [off-list ref] wrote:
quoted
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
quoted
@@ -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
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help