Merge branch 'fc/completion-updates' into maint

Command line completion updates.

* fc/completion-updates:
  completion: bash: add correct suffix in variables
  completion: bash: fix for multiple dash commands
  completion: bash: fix for suboptions with value
  completion: bash: fix prefix detection in branch.*
This commit is contained in:
Junio C Hamano 2021-10-12 13:51:24 -07:00
commit c5d1c7028d
2 changed files with 22 additions and 7 deletions

View file

@ -356,7 +356,7 @@ __gitcomp ()
local cur_="${3-$cur}"
case "$cur_" in
--*=)
*=)
;;
--no-*)
local c i=0 IFS=$' \t\n'
@ -421,7 +421,7 @@ __gitcomp_builtin ()
local incl="${2-}"
local excl="${3-}"
local var=__gitcomp_builtin_"${cmd/-/_}"
local var=__gitcomp_builtin_"${cmd//-/_}"
local options
eval "options=\${$var-}"
@ -2650,10 +2650,10 @@ __git_complete_config_variable_name ()
return
;;
branch.*)
local pfx="${cur%.*}."
cur_="${cur#*.}"
local pfx="${cur_%.*}."
cur_="${cur_#*.}"
__gitcomp_direct "$(__git_heads "$pfx" "$cur_" ".")"
__gitcomp_nl_append $'autoSetupMerge\nautoSetupRebase\n' "$pfx" "$cur_" "$sfx"
__gitcomp_nl_append $'autoSetupMerge\nautoSetupRebase\n' "$pfx" "$cur_" "${sfx- }"
return
;;
guitool.*.*)
@ -2687,7 +2687,7 @@ __git_complete_config_variable_name ()
local pfx="${cur_%.*}."
cur_="${cur_#*.}"
__git_compute_all_commands
__gitcomp_nl "$__git_all_commands" "$pfx" "$cur_" "$sfx"
__gitcomp_nl "$__git_all_commands" "$pfx" "$cur_" "${sfx- }"
return
;;
remote.*.*)
@ -2703,7 +2703,7 @@ __git_complete_config_variable_name ()
local pfx="${cur_%.*}."
cur_="${cur_#*.}"
__gitcomp_nl "$(__git_remotes)" "$pfx" "$cur_" "."
__gitcomp_nl_append "pushDefault" "$pfx" "$cur_" "$sfx"
__gitcomp_nl_append "pushDefault" "$pfx" "$cur_" "${sfx- }"
return
;;
url.*.*)

View file

@ -540,6 +540,15 @@ test_expect_success '__gitcomp - expand/narrow all negative options' '
EOF
'
test_expect_success '__gitcomp - equal skip' '
test_gitcomp "--option=" "--option=" <<-\EOF &&
EOF
test_gitcomp "option=" "option=" <<-\EOF
EOF
'
test_expect_success '__gitcomp - doesnt fail because of invalid variable name' '
__gitcomp "$invalid_variable_name"
'
@ -2380,6 +2389,12 @@ test_expect_success 'git clone --config= - value' '
EOF
'
test_expect_success 'options with value' '
test_completion "git merge -X diff-algorithm=" <<-\EOF
EOF
'
test_expect_success 'sourcing the completion script clears cached commands' '
__git_compute_all_commands &&
verbose test -n "$__git_all_commands" &&