diff options
author | Patrick Steinhardt <ps@pks.im> | 2024-05-17 08:13:36 +0200 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2024-05-17 18:26:19 +0200 |
commit | 5dd5007f8936f8d37cf95119e83039bd9237a3c5 (patch) | |
tree | 171b68f35ab95c56c899965cc6355cd1ff012e1e /contrib/completion | |
parent | The fourth batch (diff) | |
download | git-5dd5007f8936f8d37cf95119e83039bd9237a3c5.tar.xz git-5dd5007f8936f8d37cf95119e83039bd9237a3c5.zip |
completion: adapt git-config(1) to complete subcommands
With fe3ccc7aab (Merge branch 'ps/config-subcommands', 2024-05-15),
git-config(1) has gained support for subcommands. These subcommands live
next to the old, action-based mode, so that both the old and new way
continue to work.
The manpage for this command has been updated to prominently show the
subcommands, and the action-based modes are marked as deprecated. Update
Bash completion scripts accordingly to advertise subcommands instead of
actions.
Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'contrib/completion')
-rw-r--r-- | contrib/completion/git-completion.bash | 42 |
1 files changed, 31 insertions, 11 deletions
diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash index 5c0ddeb3d4..60a22d619a 100644 --- a/contrib/completion/git-completion.bash +++ b/contrib/completion/git-completion.bash @@ -2989,22 +2989,42 @@ __git_complete_config_variable_name_and_value () _git_config () { - case "$prev" in - --get|--get-all|--unset|--unset-all) - __gitcomp_nl "$(__git_config_get_set_variables)" + local subcommands subcommand + + __git_resolve_builtins "config" + + subcommands="$___git_resolved_builtins" + subcommand="$(__git_find_subcommand "$subcommands")" + + if [ -z "$subcommand" ] + then + __gitcomp "$subcommands" return - ;; - *.*) - __git_complete_config_variable_value + fi + + case "$cur" in + --*) + __gitcomp_builtin "config_$subcommand" return ;; esac - case "$cur" in - --*) - __gitcomp_builtin config + + case "$subcommand" in + get) + __gitcomp_nl "$(__git_config_get_set_variables)" ;; - *) - __git_complete_config_variable_name + set) + case "$prev" in + *.*) + __git_complete_config_variable_value + ;; + *) + __git_complete_config_variable_name + ;; + esac + ;; + unset) + __gitcomp_nl "$(__git_config_get_set_variables)" ;; esac } |