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>
This commit is contained in:
Patrick Steinhardt
2024-05-17 08:13:36 +02:00
committed by Junio C Hamano
parent 19fe900cfc
commit 5dd5007f89
2 changed files with 73 additions and 25 deletions

View File

@ -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
}